From efd424ebab3b33174233d220866b4bf2c4fae259 Mon Sep 17 00:00:00 2001 From: Matt Jaffee Date: Wed, 3 Jul 2019 11:02:59 -0500 Subject: [PATCH] add ability to disable tracing and use nopTracer Have found some potential performance or stability issues associated with lots of mutex blocking in getting a parent span's context. Want the ability to totally disable tracing to help debugging. --- cmd/server.go | 32 +++++++++++++++++--------------- ctl/server.go | 2 +- docs/configuration.md | 2 +- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/cmd/server.go b/cmd/server.go index 6e0e3368a..43432fceb 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -46,22 +46,24 @@ on the configured port.`, return errors.Wrap(err, "running server") } - // Initialize tracing in the command since it is global. - var cfg jaegercfg.Configuration - cfg.ServiceName = "pilosa" - cfg.Sampler = &jaegercfg.SamplerConfig{ - Type: Server.Config.Tracing.SamplerType, - Param: Server.Config.Tracing.SamplerParam, + if Server.Config.Tracing.SamplerType != "off" { + // Initialize tracing in the command since it is global. + var cfg jaegercfg.Configuration + cfg.ServiceName = "pilosa" + cfg.Sampler = &jaegercfg.SamplerConfig{ + Type: Server.Config.Tracing.SamplerType, + Param: Server.Config.Tracing.SamplerParam, + } + cfg.Reporter = &jaegercfg.ReporterConfig{ + LocalAgentHostPort: Server.Config.Tracing.AgentHostPort, + } + tracer, closer, err := cfg.NewTracer() + if err != nil { + return errors.Wrap(err, "initializing jaeger tracer") + } + defer closer.Close() + tracing.GlobalTracer = opentracing.NewTracer(tracer) } - cfg.Reporter = &jaegercfg.ReporterConfig{ - LocalAgentHostPort: Server.Config.Tracing.AgentHostPort, - } - tracer, closer, err := cfg.NewTracer() - if err != nil { - return errors.Wrap(err, "initializing jaeger tracer") - } - defer closer.Close() - tracing.GlobalTracer = opentracing.NewTracer(tracer) return errors.Wrap(Server.Wait(), "waiting on Server") }, diff --git a/ctl/server.go b/ctl/server.go index ab4dd3305..edeced6b4 100644 --- a/ctl/server.go +++ b/ctl/server.go @@ -77,7 +77,7 @@ func BuildServerFlags(cmd *cobra.Command, srv *server.Command) { // Tracing flags.StringVarP(&srv.Config.Tracing.AgentHostPort, "tracing.agent-host-port", "", srv.Config.Tracing.AgentHostPort, "Jaeger agent host:port.") - flags.StringVarP(&srv.Config.Tracing.SamplerType, "tracing.sampler-type", "", srv.Config.Tracing.SamplerType, "Jaeger sampler type.") + flags.StringVarP(&srv.Config.Tracing.SamplerType, "tracing.sampler-type", "", srv.Config.Tracing.SamplerType, "Jaeger sampler type or 'off' to disable tracing completely.") flags.Float64VarP(&srv.Config.Tracing.SamplerParam, "tracing.sampler-param", "", srv.Config.Tracing.SamplerParam, "Jaeger sampler parameter.") // Profiling diff --git a/docs/configuration.md b/docs/configuration.md index 8eb410de4..9c95f4536 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -377,7 +377,7 @@ The config file is in the [toml format](https://github.com/toml-lang/toml) and h #### Tracing Sampler Type -* Description: Jaeger sampler type (const, probabilistic, ratelimiting, or remote) +* Description: Jaeger sampler type (const, probabilistic, ratelimiting, or remote). Set to 'off' to disable tracing completely. * Flag: `tracing.sampler-type` * Env: `PILOSA_TRACING_SAMPLER_TYPE` * Config: