diff --git a/tracing/tracing.go b/tracing/tracing.go index a20a672f8817ebf2e7924a9e34d86eb1518c75e2..8770791e1d16259969eddc4e7eece9259c1ea189 100644 --- a/tracing/tracing.go +++ b/tracing/tracing.go @@ -83,7 +83,7 @@ func getServiceName() string { // We need to check the configuration as soon as possible, because // it's likely that client transports are created before HTTP servers, // and we need to wrap them with opencensus at creation time. -func initTracing(endpointAddr string) { +func initTracing(serviceName string) { initOnce.Do(func() { // Kill switch from environment. if s := os.Getenv("TRACING_ENABLE"); s == "0" { @@ -122,7 +122,7 @@ func initTracing(endpointAddr string) { ) otel.SetTracerProvider(tp) - Tracer = tp.Tracer(endpointAddr) + Tracer = tp.Tracer(serviceName) log.Printf("tracing enabled (report_url %s)", config.ReportURL) @@ -148,8 +148,9 @@ func WrapTransport(t http.RoundTripper) http.RoundTripper { // functionality, if globally enabled. Automatically calls Init(). func WrapHandler(h http.Handler, endpointAddr string) http.Handler { if Enabled { - initTracing(endpointAddr) - h = othttp.NewHandler(h, getServiceName()) + serviceName := getServiceName() + initTracing(serviceName) + h = othttp.NewHandler(h, serviceName) } return h }