Skip to content

Commit

Permalink
[exporter/datadog] Add configurable reporter_period for host metadata
Browse files Browse the repository at this point in the history
- make gofmt
  • Loading branch information
NassimBtk committed Nov 19, 2024
1 parent 14ebcc7 commit 88aa1fb
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions pkg/datadog/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func TestValidate(t *testing.T) {
{
name: "invalid hostname",
cfg: &Config{
API: APIConfig{Key: "notnull"},
TagsConfig: TagsConfig{Hostname: "invalid_host"},
API: APIConfig{Key: "notnull"},
TagsConfig: TagsConfig{Hostname: "invalid_host"},
HostMetadata: HostMetadataConfig{Enabled: true, ReporterPeriod: 10 * time.Minute},
},
err: "hostname field is invalid: invalid_host is not RFC1123 compliant",
Expand All @@ -65,43 +65,42 @@ func TestValidate(t *testing.T) {
{
name: "span name remapping valid",
cfg: &Config{
API: APIConfig{Key: "notnull"},
Traces: TracesExporterConfig{TracesConfig: TracesConfig{SpanNameRemappings: map[string]string{"old.opentelemetryspan.name": "updated.name"}}},
API: APIConfig{Key: "notnull"},
Traces: TracesExporterConfig{TracesConfig: TracesConfig{SpanNameRemappings: map[string]string{"old.opentelemetryspan.name": "updated.name"}}},
HostMetadata: HostMetadataConfig{Enabled: true, ReporterPeriod: 10 * time.Minute},
},
},
{
name: "span name remapping empty val",
cfg: &Config{
API: APIConfig{Key: "notnull"},
Traces: TracesExporterConfig{TracesConfig: TracesConfig{SpanNameRemappings: map[string]string{"oldname": ""}}},
API: APIConfig{Key: "notnull"},
Traces: TracesExporterConfig{TracesConfig: TracesConfig{SpanNameRemappings: map[string]string{"oldname": ""}}},
HostMetadata: HostMetadataConfig{Enabled: true, ReporterPeriod: 10 * time.Minute},
},
err: "'' is not valid value for span name remapping",
},
{
name: "span name remapping empty key",
cfg: &Config{
API: APIConfig{Key: "notnull"},
Traces: TracesExporterConfig{TracesConfig: TracesConfig{SpanNameRemappings: map[string]string{"": "newname"}}},
API: APIConfig{Key: "notnull"},
Traces: TracesExporterConfig{TracesConfig: TracesConfig{SpanNameRemappings: map[string]string{"": "newname"}}},
HostMetadata: HostMetadataConfig{Enabled: true, ReporterPeriod: 10 * time.Minute},

},
err: "'' is not valid key for span name remapping",
},
{
name: "ignore resources valid",
cfg: &Config{
API: APIConfig{Key: "notnull"},
Traces: TracesExporterConfig{TracesConfig: TracesConfig{IgnoreResources: []string{"[123]"}}},
API: APIConfig{Key: "notnull"},
Traces: TracesExporterConfig{TracesConfig: TracesConfig{IgnoreResources: []string{"[123]"}}},
HostMetadata: HostMetadataConfig{Enabled: true, ReporterPeriod: 10 * time.Minute},
},
},
{
name: "ignore resources missing bracket",
cfg: &Config{
API: APIConfig{Key: "notnull"},
Traces: TracesExporterConfig{TracesConfig: TracesConfig{IgnoreResources: []string{"[123"}}},
API: APIConfig{Key: "notnull"},
Traces: TracesExporterConfig{TracesConfig: TracesConfig{IgnoreResources: []string{"[123"}}},
HostMetadata: HostMetadataConfig{Enabled: true, ReporterPeriod: 10 * time.Minute},
},
err: "'[123' is not valid resource filter regular expression",
Expand Down Expand Up @@ -135,8 +134,8 @@ func TestValidate(t *testing.T) {
{
name: "With trace_buffer",
cfg: &Config{
API: APIConfig{Key: "notnull"},
Traces: TracesExporterConfig{TraceBuffer: 10},
API: APIConfig{Key: "notnull"},
Traces: TracesExporterConfig{TraceBuffer: 10},
HostMetadata: HostMetadataConfig{Enabled: true, ReporterPeriod: 10 * time.Minute},
},
},
Expand Down Expand Up @@ -190,7 +189,7 @@ func TestValidate(t *testing.T) {
{
name: "Invalid reporter_period",
cfg: &Config{
API: APIConfig{Key: "notnull"},
API: APIConfig{Key: "notnull"},
HostMetadata: HostMetadataConfig{Enabled: true, ReporterPeriod: 0},
},
err: "reporter_period must be a positive duration",
Expand Down

0 comments on commit 88aa1fb

Please sign in to comment.