diff --git a/cmd/query/app/tracing.go b/cmd/query/app/tracing.go new file mode 100644 index 000000000000..da753c85407a --- /dev/null +++ b/cmd/query/app/tracing.go @@ -0,0 +1,25 @@ +package app + +import ( + "os" + + jaegerClientConfig "github.com/uber/jaeger-client-go/config" +) + +func TracerConfig() (*jaegerClientConfig.Configuration, error) { + cfg, err := jaegerClientConfig.FromEnv() + if err != nil { + return nil, err + } + // backwards compatibility + if e := os.Getenv("JAEGER_RPC_METRICS"); e == "" { + cfg.RPCMetrics = true + } + if e := os.Getenv("JAEGER_SAMPLER_TYPE"); e == "" { + cfg.Sampler.Type = "probabilistic" + } + if e := os.Getenv("JAEGER_SAMPLER_PARAM"); e == "" { + cfg.Sampler.Param = 1.0 + } + return cfg, nil +} diff --git a/cmd/query/main.go b/cmd/query/main.go index e2e2aff7361e..ad70ab3dcfce 100644 --- a/cmd/query/main.go +++ b/cmd/query/main.go @@ -64,14 +64,11 @@ func main() { baseFactory := svc.MetricsFactory.Namespace(metrics.NSOptions{Name: "jaeger"}) metricsFactory := baseFactory.Namespace(metrics.NSOptions{Name: "query"}) - tracer, closer, err := jaegerClientConfig.Configuration{ - ServiceName: "jaeger-query", - Sampler: &jaegerClientConfig.SamplerConfig{ - Type: "probabilistic", - Param: 1.0, - }, - RPCMetrics: true, - }.NewTracer( + cfg, err := app.TracerConfig() + if err != nil { + logger.Fatal("Failed to read tracer config from env", zap.Error(err)) + } + closer, err := cfg.InitGlobalTracer("jaeger-query", jaegerClientConfig.Metrics(svc.MetricsFactory), jaegerClientConfig.Logger(jaegerClientZapLog.NewLogger(logger)), ) @@ -79,7 +76,6 @@ func main() { logger.Fatal("Failed to initialize tracer", zap.Error(err)) } defer closer.Close() - opentracing.SetGlobalTracer(tracer) queryOpts := new(app.QueryOptions).InitFromViper(v) // TODO: Need to figure out set enable/disable propagation on storage plugins. v.Set(spanstore.StoragePropagationKey, queryOpts.BearerTokenPropagation) @@ -102,7 +98,7 @@ func main() { dependencyReader, *queryServiceOptions) - server := app.NewServer(svc, queryService, queryOpts, tracer) + server := app.NewServer(svc, queryService, queryOpts, opentracing.GlobalTracer()) if err := server.Start(); err != nil { logger.Fatal("Could not start servers", zap.Error(err))