Added support for configuring trace headers for DataDog tracing

This commit is contained in:
Alex Antonov 2019-03-27 11:20:05 -05:00 committed by Traefiker Bot
parent c17de070fb
commit 1bcb3d8cc2

View file

@ -19,6 +19,10 @@ type Config struct {
GlobalTag string `description:"Key:Value tag to be set on all the spans." export:"true"` GlobalTag string `description:"Key:Value tag to be set on all the spans." export:"true"`
Debug bool `description:"Enable DataDog debug." export:"true"` Debug bool `description:"Enable DataDog debug." export:"true"`
PrioritySampling bool `description:"Enable priority sampling. When using distributed tracing, this option must be enabled in order to get all the parts of a distributed trace sampled."` PrioritySampling bool `description:"Enable priority sampling. When using distributed tracing, this option must be enabled in order to get all the parts of a distributed trace sampled."`
TraceIDHeaderName string `description:"Specifies the header name that will be used to store the trace ID." export:"true"`
ParentIDHeaderName string `description:"Specifies the header name that will be used to store the parent ID." export:"true"`
SamplingPriorityHeaderName string `description:"Specifies the header name that will be used to store the sampling priority." export:"true"`
BagagePrefixHeaderName string `description:"specifies the header name prefix that will be used to store baggage items in a map." export:"true"`
} }
// Setup sets up the tracer // Setup sets up the tracer
@ -35,6 +39,12 @@ func (c *Config) Setup(serviceName string) (opentracing.Tracer, io.Closer, error
datadog.WithServiceName(serviceName), datadog.WithServiceName(serviceName),
datadog.WithGlobalTag(tag[0], value), datadog.WithGlobalTag(tag[0], value),
datadog.WithDebugMode(c.Debug), datadog.WithDebugMode(c.Debug),
datadog.WithPropagator(datadog.NewPropagator(&datadog.PropagatorConfig{
TraceHeader: c.TraceIDHeaderName,
ParentHeader: c.ParentIDHeaderName,
PriorityHeader: c.SamplingPriorityHeaderName,
BaggagePrefix: c.BagagePrefixHeaderName,
})),
} }
if c.PrioritySampling { if c.PrioritySampling {
opts = append(opts, datadog.WithPrioritySampling()) opts = append(opts, datadog.WithPrioritySampling())