Skip to content

Commit

Permalink
Remove UseDatadog from tracing config (#272)
Browse files Browse the repository at this point in the history
This was introduced in #247 to allow applications to
use the datadog tracing api directly instead of an opentracing compatible version.

The issue is that when `UseDatadog` is enabled, opentracing.GlobalTracer is set to a noop tracer
so other packages in netlify-commons that emit traces (e.g router) don't work as expected.

We don't actually need this option because `opentracer.New` already calls `tracer.Start` so
applications should be able to use both the opentracing and datadog tracing api.
  • Loading branch information
mrdg authored Dec 15, 2021
1 parent 6386f12 commit 8bc165b
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions tracing/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ type Config struct {
Port string `default:"8126"`
Tags map[string]string
EnableDebug bool `default:"false" split_words:"true" mapstructure:"enable_debug" json:"enable_debug" yaml:"enable_debug"`
UseDatadog bool `default:"false" split_words:"true" mapstructure:"use_datadog" json:"use_datadog" yaml:"use_datadog"`
}

func Configure(tc *Config, log logrus.FieldLogger, svcName string) {
Expand All @@ -35,12 +34,6 @@ func Configure(tc *Config, log logrus.FieldLogger, svcName string) {
tracer.WithLogger(debugLogger{log.WithField("component", "opentracing")}),
}

if tc.UseDatadog {
tracerOps = append(tracerOps, tracer.WithLogger(debugLogger{log.WithField("component", "datadog")}))
} else {
tracerOps = append(tracerOps, tracer.WithLogger(debugLogger{log.WithField("component", "opentracing")}))
}

var serviceTagSet bool
for k, v := range tc.Tags {
if strings.ToLower(k) == "service" {
Expand All @@ -54,11 +47,7 @@ func Configure(tc *Config, log logrus.FieldLogger, svcName string) {
tracerOps = append(tracerOps, tracer.WithGlobalTag("service", svcName))
}

if tc.UseDatadog {
tracer.Start(tracerOps...)
} else {
t = opentracer.New(tracerOps...)
}
t = opentracer.New(tracerOps...)
}
opentracing.SetGlobalTracer(t)
}
Expand Down

0 comments on commit 8bc165b

Please sign in to comment.