Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly shutdown tracer when the work is done #13226

Merged
merged 1 commit into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/activator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ func main() {
go throttler.Run(ctx, transport, networkConfig.EnableMeshPodAddressability, networkConfig.MeshCompatibilityMode)

oct := tracing.NewOpenCensusTracer(tracing.WithExporterFull(networking.ActivatorServiceName, env.PodIP, logger))
defer oct.Shutdown(context.Background())

tracerUpdater := configmap.TypeFilter(&tracingconfig.Config{})(func(name string, value interface{}) {
cfg := value.(*tracingconfig.Config)
Expand Down
23 changes: 13 additions & 10 deletions pkg/queue/sharedmain/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,18 @@ func Main(opts ...Option) error {
zap.String(logkey.Pod, env.ServingPod))

d.Logger = logger
d.Transport = buildTransport(env, logger)
d.Transport = buildTransport(env)

if env.TracingConfigBackend != tracingconfig.None {
oct := tracing.NewOpenCensusTracer(tracing.WithExporterFull(env.ServingPod, env.ServingPodIP, logger))
oct.ApplyConfig(&tracingconfig.Config{
Backend: env.TracingConfigBackend,
Debug: env.TracingConfigDebug,
ZipkinEndpoint: env.TracingConfigZipkinEndpoint,
SampleRate: env.TracingConfigSampleRate,
})
defer oct.Shutdown(context.Background())
}

// allow extensions to read d and return modified context and transport
for _, opts := range opts {
Expand Down Expand Up @@ -400,7 +411,7 @@ func buildServer(ctx context.Context, env config, transport http.RoundTripper, p
return pkgnet.NewServer(":"+env.QueueServingPort, composedHandler), drainer.Drain
}

func buildTransport(env config, logger *zap.SugaredLogger) http.RoundTripper {
func buildTransport(env config) http.RoundTripper {
maxIdleConns := 1000 // TODO: somewhat arbitrary value for CC=0, needs experimental validation.
if env.ContainerConcurrency > 0 {
maxIdleConns = env.ContainerConcurrency
Expand All @@ -412,14 +423,6 @@ func buildTransport(env config, logger *zap.SugaredLogger) http.RoundTripper {
return transport
}

oct := tracing.NewOpenCensusTracer(tracing.WithExporterFull(env.ServingPod, env.ServingPodIP, logger))
oct.ApplyConfig(&tracingconfig.Config{
Backend: env.TracingConfigBackend,
Debug: env.TracingConfigDebug,
ZipkinEndpoint: env.TracingConfigZipkinEndpoint,
SampleRate: env.TracingConfigSampleRate,
})

return &ochttp.Transport{
Base: transport,
Propagation: tracecontextb3.TraceContextB3Egress,
Expand Down