Skip to content
Snippets Groups Projects
Commit 6b04d2d6 authored by ale's avatar ale
Browse files

Use service name for the Tracer

parent 25fdf0ef
No related branches found
No related tags found
No related merge requests found
......@@ -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
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment