fix: Datadog case.
This commit is contained in:
parent
259c7adc81
commit
306e5081d9
22 changed files with 87 additions and 87 deletions
|
@ -186,7 +186,7 @@ func TestDo_globalConfiguration(t *testing.T) {
|
|||
Prometheus: &types.Prometheus{
|
||||
Buckets: []float64{0.1, 0.3, 1.2, 5},
|
||||
},
|
||||
DataDog: &types.DataDog{
|
||||
Datadog: &types.Datadog{
|
||||
Address: "localhost:8181",
|
||||
PushInterval: 12,
|
||||
},
|
||||
|
@ -226,7 +226,7 @@ func TestDo_globalConfiguration(t *testing.T) {
|
|||
Debug: true,
|
||||
SampleRate: 53,
|
||||
},
|
||||
DataDog: &datadog.Config{
|
||||
Datadog: &datadog.Config{
|
||||
LocalAgentHostPort: "ggg",
|
||||
GlobalTag: "eee",
|
||||
Debug: true,
|
||||
|
|
|
@ -119,7 +119,7 @@
|
|||
buckets = [42.0, 42.0]
|
||||
entryPoint = "foobar"
|
||||
middlewares = ["foobar", "foobar"]
|
||||
[metrics.dataDog]
|
||||
[metrics.datadog]
|
||||
address = "foobar"
|
||||
pushInterval = "10s"
|
||||
[metrics.statsD]
|
||||
|
@ -179,7 +179,7 @@
|
|||
id128Bit = true
|
||||
debug = true
|
||||
sampleRate = 42.0
|
||||
[tracing.dataDog]
|
||||
[tracing.datadog]
|
||||
localAgentHostPort = "foobar"
|
||||
globalTag = "foobar"
|
||||
debug = true
|
||||
|
|
|
@ -143,7 +143,7 @@ func Test_decodeFileToNode_Toml(t *testing.T) {
|
|||
{Name: "format", Value: "foobar"},
|
||||
{Name: "level", Value: "foobar"}}},
|
||||
{Name: "metrics", Children: []*parser.Node{
|
||||
{Name: "dataDog", Children: []*parser.Node{
|
||||
{Name: "datadog", Children: []*parser.Node{
|
||||
{Name: "address", Value: "foobar"},
|
||||
{Name: "pushInterval", Value: "10s"}}},
|
||||
{Name: "influxDB", Children: []*parser.Node{
|
||||
|
@ -251,7 +251,7 @@ func Test_decodeFileToNode_Toml(t *testing.T) {
|
|||
{Name: "maxIdleConnsPerHost", Value: "42"},
|
||||
{Name: "rootCAs", Value: "foobar,foobar"}}},
|
||||
{Name: "tracing", Children: []*parser.Node{
|
||||
{Name: "dataDog", Children: []*parser.Node{
|
||||
{Name: "datadog", Children: []*parser.Node{
|
||||
{Name: "bagagePrefixHeaderName", Value: "foobar"},
|
||||
{Name: "debug", Value: "true"},
|
||||
{Name: "globalTag", Value: "foobar"},
|
||||
|
@ -378,7 +378,7 @@ func Test_decodeFileToNode_Yaml(t *testing.T) {
|
|||
{Name: "format", Value: "foobar"},
|
||||
{Name: "level", Value: "foobar"}}},
|
||||
{Name: "metrics", Children: []*parser.Node{
|
||||
{Name: "dataDog", Children: []*parser.Node{
|
||||
{Name: "datadog", Children: []*parser.Node{
|
||||
{Name: "address", Value: "foobar"},
|
||||
{Name: "pushInterval", Value: "10s"}}},
|
||||
{Name: "influxDB", Children: []*parser.Node{
|
||||
|
@ -486,7 +486,7 @@ func Test_decodeFileToNode_Yaml(t *testing.T) {
|
|||
{Name: "maxIdleConnsPerHost", Value: "42"},
|
||||
{Name: "rootCAs", Value: "foobar,foobar"}}},
|
||||
{Name: "tracing", Children: []*parser.Node{
|
||||
{Name: "dataDog", Children: []*parser.Node{
|
||||
{Name: "datadog", Children: []*parser.Node{
|
||||
{Name: "bagagePrefixHeaderName", Value: "foobar"},
|
||||
{Name: "debug", Value: "true"},
|
||||
{Name: "globalTag", Value: "foobar"},
|
||||
|
|
|
@ -119,7 +119,7 @@
|
|||
buckets = [42.0, 42.0]
|
||||
entryPoint = "foobar"
|
||||
middlewares = ["foobar", "foobar"]
|
||||
[metrics.dataDog]
|
||||
[metrics.datadog]
|
||||
address = "foobar"
|
||||
pushInterval = "10s"
|
||||
[metrics.statsD]
|
||||
|
@ -179,7 +179,7 @@
|
|||
id128Bit = true
|
||||
debug = true
|
||||
sampleRate = 42.0
|
||||
[tracing.dataDog]
|
||||
[tracing.datadog]
|
||||
localAgentHostPort = "foobar"
|
||||
globalTag = "foobar"
|
||||
debug = true
|
||||
|
|
|
@ -130,7 +130,7 @@ metrics:
|
|||
middlewares:
|
||||
- foobar
|
||||
- foobar
|
||||
dataDog:
|
||||
datadog:
|
||||
address: foobar
|
||||
pushInterval: 10s
|
||||
statsD:
|
||||
|
@ -190,7 +190,7 @@ tracing:
|
|||
id128Bit: true
|
||||
debug: true
|
||||
sampleRate: 42
|
||||
dataDog:
|
||||
datadog:
|
||||
localAgentHostPort: foobar
|
||||
globalTag: foobar
|
||||
debug: true
|
||||
|
|
|
@ -139,7 +139,7 @@ type Tracing struct {
|
|||
SpanNameLimit int `description:"Set the maximum character limit for Span names (default 0 = no limit)." json:"spanNameLimit,omitempty" toml:"spanNameLimit,omitempty" yaml:"spanNameLimit,omitempty" export:"true"`
|
||||
Jaeger *jaeger.Config `description:"Settings for Jaeger." json:"jaeger,omitempty" toml:"jaeger,omitempty" yaml:"jaeger,omitempty" export:"true" label:"allowEmpty"`
|
||||
Zipkin *zipkin.Config `description:"Settings for Zipkin." json:"zipkin,omitempty" toml:"zipkin,omitempty" yaml:"zipkin,omitempty" export:"true" label:"allowEmpty"`
|
||||
DataDog *datadog.Config `description:"Settings for DataDog." json:"dataDog,omitempty" toml:"dataDog,omitempty" yaml:"dataDog,omitempty" export:"true" label:"allowEmpty"`
|
||||
Datadog *datadog.Config `description:"Settings for Datadog." json:"datadog,omitempty" toml:"datadog,omitempty" yaml:"datadog,omitempty" export:"true" label:"allowEmpty"`
|
||||
Instana *instana.Config `description:"Settings for Instana." json:"instana,omitempty" toml:"instana,omitempty" yaml:"instana,omitempty" export:"true" label:"allowEmpty"`
|
||||
Haystack *haystack.Config `description:"Settings for Haystack." json:"haystack,omitempty" toml:"haystack,omitempty" yaml:"haystack,omitempty" export:"true" label:"allowEmpty"`
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ const (
|
|||
)
|
||||
|
||||
// RegisterDatadog registers the metrics pusher if this didn't happen yet and creates a datadog Registry instance.
|
||||
func RegisterDatadog(ctx context.Context, config *types.DataDog) Registry {
|
||||
func RegisterDatadog(ctx context.Context, config *types.Datadog) Registry {
|
||||
if datadogTicker == nil {
|
||||
datadogTicker = initDatadogClient(ctx, config)
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ func RegisterDatadog(ctx context.Context, config *types.DataDog) Registry {
|
|||
return registry
|
||||
}
|
||||
|
||||
func initDatadogClient(ctx context.Context, config *types.DataDog) *time.Ticker {
|
||||
func initDatadogClient(ctx context.Context, config *types.Datadog) *time.Ticker {
|
||||
address := config.Address
|
||||
if len(address) == 0 {
|
||||
address = "localhost:8125"
|
||||
|
|
|
@ -16,7 +16,7 @@ func TestDatadog(t *testing.T) {
|
|||
// This is needed to make sure that UDP Listener listens for data a bit longer, otherwise it will quit after a millisecond
|
||||
udp.Timeout = 5 * time.Second
|
||||
|
||||
datadogRegistry := RegisterDatadog(context.Background(), &types.DataDog{Address: ":18125", PushInterval: types.Duration(time.Second), AddEntryPointsLabels: true, AddServicesLabels: true})
|
||||
datadogRegistry := RegisterDatadog(context.Background(), &types.Datadog{Address: ":18125", PushInterval: types.Duration(time.Second), AddEntryPointsLabels: true, AddServicesLabels: true})
|
||||
defer StopDatadog()
|
||||
|
||||
if !datadogRegistry.IsEpEnabled() || !datadogRegistry.IsSvcEnabled() {
|
||||
|
|
|
@ -66,11 +66,11 @@ func setupTracing(conf *static.Tracing) tracing.Backend {
|
|||
}
|
||||
}
|
||||
|
||||
if conf.DataDog != nil {
|
||||
if conf.Datadog != nil {
|
||||
if backend != nil {
|
||||
log.WithoutContext().Error("Multiple tracing backend are not supported: cannot create DataDog backend.")
|
||||
log.WithoutContext().Error("Multiple tracing backend are not supported: cannot create Datadog backend.")
|
||||
} else {
|
||||
backend = conf.DataDog
|
||||
backend = conf.Datadog
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -307,11 +307,11 @@ func registerMetricClients(metricsConfig *types.Metrics) metrics.Registry {
|
|||
}
|
||||
}
|
||||
|
||||
if metricsConfig.DataDog != nil {
|
||||
if metricsConfig.Datadog != nil {
|
||||
ctx := log.With(context.Background(), log.Str(log.MetricsProviderName, "datadog"))
|
||||
registries = append(registries, metrics.RegisterDatadog(ctx, metricsConfig.DataDog))
|
||||
log.FromContext(ctx).Debugf("Configured DataDog metrics: pushing to %s once every %s",
|
||||
metricsConfig.DataDog.Address, metricsConfig.DataDog.PushInterval)
|
||||
registries = append(registries, metrics.RegisterDatadog(ctx, metricsConfig.Datadog))
|
||||
log.FromContext(ctx).Debugf("Configured Datadog metrics: pushing to %s once every %s",
|
||||
metricsConfig.Datadog.Address, metricsConfig.Datadog.PushInterval)
|
||||
}
|
||||
|
||||
if metricsConfig.StatsD != nil {
|
||||
|
|
|
@ -17,7 +17,7 @@ const Name = "datadog"
|
|||
type Config struct {
|
||||
LocalAgentHostPort string `description:"Set datadog-agent's host:port that the reporter will used." json:"localAgentHostPort,omitempty" toml:"localAgentHostPort,omitempty" yaml:"localAgentHostPort,omitempty"`
|
||||
GlobalTag string `description:"Key:Value tag to be set on all the spans." json:"globalTag,omitempty" toml:"globalTag,omitempty" yaml:"globalTag,omitempty" export:"true"`
|
||||
Debug bool `description:"Enable DataDog debug." json:"debug,omitempty" toml:"debug,omitempty" yaml:"debug,omitempty" export:"true"`
|
||||
Debug bool `description:"Enable Datadog debug." json:"debug,omitempty" toml:"debug,omitempty" yaml:"debug,omitempty" 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." json:"prioritySampling,omitempty" toml:"prioritySampling,omitempty" yaml:"prioritySampling,omitempty"`
|
||||
TraceIDHeaderName string `description:"Specifies the header name that will be used to store the trace ID." json:"traceIDHeaderName,omitempty" toml:"traceIDHeaderName,omitempty" yaml:"traceIDHeaderName,omitempty" export:"true"`
|
||||
ParentIDHeaderName string `description:"Specifies the header name that will be used to store the parent ID." json:"parentIDHeaderName,omitempty" toml:"parentIDHeaderName,omitempty" yaml:"parentIDHeaderName,omitempty" export:"true"`
|
||||
|
@ -62,7 +62,7 @@ func (c *Config) Setup(serviceName string) (opentracing.Tracer, io.Closer, error
|
|||
// Without this, child spans are getting the NOOP tracer
|
||||
opentracing.SetGlobalTracer(tracer)
|
||||
|
||||
log.WithoutContext().Debug("DataDog tracer configured")
|
||||
log.WithoutContext().Debug("Datadog tracer configured")
|
||||
|
||||
return tracer, nil, nil
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ func (c *Config) Setup(serviceName string) (opentracing.Tracer, io.Closer, error
|
|||
// Without this, child spans are getting the NOOP tracer
|
||||
opentracing.SetGlobalTracer(tracer)
|
||||
|
||||
log.WithoutContext().Debug("DataDog tracer configured")
|
||||
log.WithoutContext().Debug("haystack tracer configured")
|
||||
|
||||
return tracer, closer, nil
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
// Metrics provides options to expose and send Traefik metrics to different third party monitoring systems.
|
||||
type Metrics struct {
|
||||
Prometheus *Prometheus `description:"Prometheus metrics exporter type." json:"prometheus,omitempty" toml:"prometheus,omitempty" yaml:"prometheus,omitempty" export:"true" label:"allowEmpty"`
|
||||
DataDog *DataDog `description:"DataDog metrics exporter type." json:"dataDog,omitempty" toml:"dataDog,omitempty" yaml:"dataDog,omitempty" export:"true" label:"allowEmpty"`
|
||||
Datadog *Datadog `description:"Datadog metrics exporter type." json:"datadog,omitempty" toml:"datadog,omitempty" yaml:"datadog,omitempty" export:"true" label:"allowEmpty"`
|
||||
StatsD *Statsd `description:"StatsD metrics exporter type." json:"statsD,omitempty" toml:"statsD,omitempty" yaml:"statsD,omitempty" export:"true" label:"allowEmpty"`
|
||||
InfluxDB *InfluxDB `description:"InfluxDB metrics exporter type." json:"influxDB,omitempty" toml:"influxDB,omitempty" yaml:"influxDB,omitempty" label:"allowEmpty"`
|
||||
}
|
||||
|
@ -26,16 +26,16 @@ func (p *Prometheus) SetDefaults() {
|
|||
p.AddServicesLabels = true
|
||||
}
|
||||
|
||||
// DataDog contains address and metrics pushing interval configuration.
|
||||
type DataDog struct {
|
||||
Address string `description:"DataDog's address." json:"address,omitempty" toml:"address,omitempty" yaml:"address,omitempty"`
|
||||
PushInterval Duration `description:"DataDog push interval." json:"pushInterval,omitempty" toml:"pushInterval,omitempty" yaml:"pushInterval,omitempty" export:"true"`
|
||||
// Datadog contains address and metrics pushing interval configuration.
|
||||
type Datadog struct {
|
||||
Address string `description:"Datadog's address." json:"address,omitempty" toml:"address,omitempty" yaml:"address,omitempty"`
|
||||
PushInterval Duration `description:"Datadog push interval." json:"pushInterval,omitempty" toml:"pushInterval,omitempty" yaml:"pushInterval,omitempty" export:"true"`
|
||||
AddEntryPointsLabels bool `description:"Enable metrics on entry points." json:"addEntryPointsLabels,omitempty" toml:"addEntryPointsLabels,omitempty" yaml:"addEntryPointsLabels,omitempty" export:"true"`
|
||||
AddServicesLabels bool `description:"Enable metrics on services." json:"addServicesLabels,omitempty" toml:"addServicesLabels,omitempty" yaml:"addServicesLabels,omitempty" export:"true"`
|
||||
}
|
||||
|
||||
// SetDefaults sets the default values.
|
||||
func (d *DataDog) SetDefaults() {
|
||||
func (d *Datadog) SetDefaults() {
|
||||
d.Address = "localhost:8125"
|
||||
d.PushInterval = Duration(10 * time.Second)
|
||||
d.AddEntryPointsLabels = true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue