From 6b04d2d67aa72df2da29298c023a3be5150e123c Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Sat, 13 Aug 2022 20:45:17 +0100 Subject: [PATCH] Use service name for the Tracer --- tracing/tracing.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tracing/tracing.go b/tracing/tracing.go index a20a672..8770791 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 } -- GitLab