From 1262a34c69a9c398aa0e141c51ed392a57f6564d Mon Sep 17 00:00:00 2001 From: Jade Guiton Date: Wed, 4 Dec 2024 15:25:11 +0100 Subject: [PATCH 1/8] Only start `Reporter` if `HostMetadata.Enabled` --- exporter/datadogexporter/factory.go | 55 ++++++++++++++----- .../datadogexporter/logs_exporter_test.go | 6 -- .../datadogexporter/metrics_exporter_test.go | 6 -- .../datadogexporter/traces_exporter_test.go | 15 +---- 4 files changed, 41 insertions(+), 41 deletions(-) diff --git a/exporter/datadogexporter/factory.go b/exporter/datadogexporter/factory.go index 3ba017623954..d02cdd147813 100644 --- a/exporter/datadogexporter/factory.go +++ b/exporter/datadogexporter/factory.go @@ -269,11 +269,20 @@ func (f *factory) createMetricsExporter( statsIn := make(chan []byte, 1000) statsv := set.BuildInfo.Command + set.BuildInfo.Version f.consumeStatsPayload(ctx, &wg, statsIn, statsWriter, statsv, acfg.AgentVersion, set.Logger) - pcfg := newMetadataConfigfromConfig(cfg) - metadataReporter, err := f.Reporter(set, pcfg) - if err != nil { - cancel() - return nil, fmt.Errorf("failed to build host metadata reporter: %w", err) + + // These variables are referenced below, but only used if HostMetadata.Enabled + var ( + pcfg hostmetadata.PusherConfig + metadataReporter *inframetadata.Reporter + ) + if cfg.HostMetadata.Enabled { + pcfg := newMetadataConfigfromConfig(cfg) + var err error + metadataReporter, err = f.Reporter(set, pcfg) + if err != nil { + cancel() + return nil, fmt.Errorf("failed to build host metadata reporter: %w", err) + } } if cfg.OnlyMetadata { @@ -374,11 +383,19 @@ func (f *factory) createTracesExporter( return nil, fmt.Errorf("failed to start trace-agent: %w", err) } - pcfg := newMetadataConfigfromConfig(cfg) - metadataReporter, err := f.Reporter(set, pcfg) - if err != nil { - cancel() - return nil, fmt.Errorf("failed to build host metadata reporter: %w", err) + // These variables are referenced below, but only used if HostMetadata.Enabled + var ( + pcfg hostmetadata.PusherConfig + metadataReporter *inframetadata.Reporter + ) + if cfg.HostMetadata.Enabled { + pcfg = newMetadataConfigfromConfig(cfg) + var err error + metadataReporter, err = f.Reporter(set, pcfg) + if err != nil { + cancel() + return nil, fmt.Errorf("failed to build host metadata reporter: %w", err) + } } if cfg.OnlyMetadata { @@ -462,11 +479,19 @@ func (f *factory) createLogsExporter( ctx, cancel := context.WithCancel(ctx) // cancel() runs on shutdown - pcfg := newMetadataConfigfromConfig(cfg) - metadataReporter, err := f.Reporter(set, pcfg) - if err != nil { - cancel() - return nil, fmt.Errorf("failed to build host metadata reporter: %w", err) + // These variables are referenced below, but only used if HostMetadata.Enabled + var ( + pcfg hostmetadata.PusherConfig + metadataReporter *inframetadata.Reporter + ) + if cfg.HostMetadata.Enabled { + pcfg = newMetadataConfigfromConfig(cfg) + var err error + metadataReporter, err = f.Reporter(set, pcfg) + if err != nil { + cancel() + return nil, fmt.Errorf("failed to build host metadata reporter: %w", err) + } } attributesTranslator, err := f.AttributesTranslator(set.TelemetrySettings) diff --git a/exporter/datadogexporter/logs_exporter_test.go b/exporter/datadogexporter/logs_exporter_test.go index a2837353def9..941561890853 100644 --- a/exporter/datadogexporter/logs_exporter_test.go +++ b/exporter/datadogexporter/logs_exporter_test.go @@ -230,9 +230,6 @@ func TestLogsExporter(t *testing.T) { Endpoint: server.URL, }, }, - HostMetadata: HostMetadataConfig{ - ReporterPeriod: 30 * time.Minute, - }, } params := exportertest.NewNopSettings() @@ -598,9 +595,6 @@ func TestLogsAgentExporter(t *testing.T) { CompressionLevel: 6, BatchWait: 1, }, - HostMetadata: HostMetadataConfig{ - ReporterPeriod: 30 * time.Minute, - }, } params := exportertest.NewNopSettings() f := NewFactory() diff --git a/exporter/datadogexporter/metrics_exporter_test.go b/exporter/datadogexporter/metrics_exporter_test.go index 7d973171c850..0ec28bfe0281 100644 --- a/exporter/datadogexporter/metrics_exporter_test.go +++ b/exporter/datadogexporter/metrics_exporter_test.go @@ -58,9 +58,6 @@ func TestNewExporter(t *testing.T) { CumulativeMonotonicMode: CumulativeMonotonicSumModeToDelta, }, }, - HostMetadata: HostMetadataConfig{ - ReporterPeriod: 30 * time.Minute, - }, } cfg.HostMetadata.SetSourceTimeout(50 * time.Millisecond) params := exportertest.NewNopSettings() @@ -439,9 +436,6 @@ func TestNewExporter_Zorkian(t *testing.T) { CumulativeMonotonicMode: CumulativeMonotonicSumModeToDelta, }, }, - HostMetadata: HostMetadataConfig{ - ReporterPeriod: 30 * time.Minute, - }, } params := exportertest.NewNopSettings() f := NewFactory() diff --git a/exporter/datadogexporter/traces_exporter_test.go b/exporter/datadogexporter/traces_exporter_test.go index 68aff8b3e1ea..54e4aaf73e4e 100644 --- a/exporter/datadogexporter/traces_exporter_test.go +++ b/exporter/datadogexporter/traces_exporter_test.go @@ -145,9 +145,6 @@ func TestTracesSource(t *testing.T) { IgnoreResources: []string{}, }, }, - HostMetadata: HostMetadataConfig{ - ReporterPeriod: 30 * time.Minute, - }, } assert := assert.New(t) @@ -270,9 +267,6 @@ func TestTraceExporter(t *testing.T) { }, TraceBuffer: 2, }, - HostMetadata: HostMetadataConfig{ - ReporterPeriod: 30 * time.Minute, - }, } cfg.Traces.SetFlushInterval(0.1) @@ -298,11 +292,7 @@ func TestNewTracesExporter(t *testing.T) { metricsServer := testutil.DatadogServerMock() defer metricsServer.Close() - cfg := &Config{ - HostMetadata: HostMetadataConfig{ - ReporterPeriod: 30 * time.Minute, - }, - } + cfg := &Config{} cfg.API.Key = "ddog_32_characters_long_api_key1" cfg.Metrics.TCPAddrConfig.Endpoint = metricsServer.URL params := exportertest.NewNopSettings() @@ -368,9 +358,6 @@ func TestPushTraceData_NewEnvConvention(t *testing.T) { Traces: TracesConfig{ TCPAddrConfig: confignet.TCPAddrConfig{Endpoint: server.URL}, }, - HostMetadata: HostMetadataConfig{ - ReporterPeriod: 30 * time.Minute, - }, } cfg.Traces.SetFlushInterval(0.1) From a03a583855d7236cd703c82f714ac52f2a26a056 Mon Sep 17 00:00:00 2001 From: Jade Guiton Date: Wed, 4 Dec 2024 16:02:25 +0100 Subject: [PATCH 2/8] Shadowing is bad, mkay? --- exporter/datadogexporter/factory.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/exporter/datadogexporter/factory.go b/exporter/datadogexporter/factory.go index d02cdd147813..87792285a408 100644 --- a/exporter/datadogexporter/factory.go +++ b/exporter/datadogexporter/factory.go @@ -276,8 +276,7 @@ func (f *factory) createMetricsExporter( metadataReporter *inframetadata.Reporter ) if cfg.HostMetadata.Enabled { - pcfg := newMetadataConfigfromConfig(cfg) - var err error + pcfg = newMetadataConfigfromConfig(cfg) metadataReporter, err = f.Reporter(set, pcfg) if err != nil { cancel() @@ -390,7 +389,6 @@ func (f *factory) createTracesExporter( ) if cfg.HostMetadata.Enabled { pcfg = newMetadataConfigfromConfig(cfg) - var err error metadataReporter, err = f.Reporter(set, pcfg) if err != nil { cancel() @@ -486,7 +484,6 @@ func (f *factory) createLogsExporter( ) if cfg.HostMetadata.Enabled { pcfg = newMetadataConfigfromConfig(cfg) - var err error metadataReporter, err = f.Reporter(set, pcfg) if err != nil { cancel() From d5872775110d264fdd0188c7407c3cb2770974ce Mon Sep 17 00:00:00 2001 From: Jade Guiton Date: Wed, 4 Dec 2024 16:25:54 +0100 Subject: [PATCH 3/8] Fix test that was modifying config in-flight --- exporter/datadogexporter/metrics_exporter_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/exporter/datadogexporter/metrics_exporter_test.go b/exporter/datadogexporter/metrics_exporter_test.go index 0ec28bfe0281..1527f88b11bc 100644 --- a/exporter/datadogexporter/metrics_exporter_test.go +++ b/exporter/datadogexporter/metrics_exporter_test.go @@ -60,6 +60,9 @@ func TestNewExporter(t *testing.T) { }, } cfg.HostMetadata.SetSourceTimeout(50 * time.Millisecond) + cfg.HostMetadata.Enabled = true + cfg.HostMetadata.HostnameSource = HostnameSourceFirstResource + params := exportertest.NewNopSettings() f := NewFactory() @@ -73,8 +76,6 @@ func TestNewExporter(t *testing.T) { require.NoError(t, err) assert.Empty(t, server.MetadataChan) - cfg.HostMetadata.Enabled = true - cfg.HostMetadata.HostnameSource = HostnameSourceFirstResource testMetrics = pmetric.NewMetrics() testutil.TestMetrics.CopyTo(testMetrics) err = exp.ConsumeMetrics(context.Background(), testMetrics) From 035cf826b4d6ccb7adb973f8c674a139c2b16d03 Mon Sep 17 00:00:00 2001 From: Jade Guiton Date: Wed, 4 Dec 2024 16:36:27 +0100 Subject: [PATCH 4/8] Add `ReporterPeriod` to test config --- exporter/datadogexporter/metrics_exporter_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/exporter/datadogexporter/metrics_exporter_test.go b/exporter/datadogexporter/metrics_exporter_test.go index 1527f88b11bc..6c865df1b5e5 100644 --- a/exporter/datadogexporter/metrics_exporter_test.go +++ b/exporter/datadogexporter/metrics_exporter_test.go @@ -21,6 +21,7 @@ import ( "github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata" "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes" "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes/source" + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/datadog/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component/componenttest" @@ -58,10 +59,13 @@ func TestNewExporter(t *testing.T) { CumulativeMonotonicMode: CumulativeMonotonicSumModeToDelta, }, }, + HostMetadata: config.HostMetadataConfig{ + Enabled: true, + ReporterPeriod: 30 * time.Minute, + HostnameSource: HostnameSourceFirstResource, + }, } cfg.HostMetadata.SetSourceTimeout(50 * time.Millisecond) - cfg.HostMetadata.Enabled = true - cfg.HostMetadata.HostnameSource = HostnameSourceFirstResource params := exportertest.NewNopSettings() f := NewFactory() From 33e1fb1ac6da91163fb68dc9ab16d199c1dcce70 Mon Sep 17 00:00:00 2001 From: Jade Guiton Date: Wed, 4 Dec 2024 17:04:33 +0100 Subject: [PATCH 5/8] Lint --- exporter/datadogexporter/metrics_exporter_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exporter/datadogexporter/metrics_exporter_test.go b/exporter/datadogexporter/metrics_exporter_test.go index 6c865df1b5e5..e7d2aede5b2c 100644 --- a/exporter/datadogexporter/metrics_exporter_test.go +++ b/exporter/datadogexporter/metrics_exporter_test.go @@ -21,7 +21,6 @@ import ( "github.com/DataDog/opentelemetry-mapping-go/pkg/inframetadata" "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes" "github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes/source" - "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/datadog/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component/componenttest" @@ -32,6 +31,8 @@ import ( conventions127 "go.opentelemetry.io/collector/semconv/v1.27.0" conventions "go.opentelemetry.io/collector/semconv/v1.6.1" "go.uber.org/zap" + + "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/datadog/config" ) func TestNewExporter(t *testing.T) { From d3aeb9806ccdf9778d9c1f16742a2e7b7deef79a Mon Sep 17 00:00:00 2001 From: Jade Guiton Date: Wed, 4 Dec 2024 17:16:24 +0100 Subject: [PATCH 6/8] We've fixed one, yes. But what about second broken test? --- exporter/datadogexporter/metrics_exporter_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/exporter/datadogexporter/metrics_exporter_test.go b/exporter/datadogexporter/metrics_exporter_test.go index e7d2aede5b2c..33dd4ddbf830 100644 --- a/exporter/datadogexporter/metrics_exporter_test.go +++ b/exporter/datadogexporter/metrics_exporter_test.go @@ -442,6 +442,11 @@ func TestNewExporter_Zorkian(t *testing.T) { CumulativeMonotonicMode: CumulativeMonotonicSumModeToDelta, }, }, + HostMetadata: config.HostMetadataConfig{ + Enabled: true, + ReporterPeriod: 30 * time.Minute, + HostnameSource: HostnameSourceFirstResource, + }, } params := exportertest.NewNopSettings() f := NewFactory() @@ -456,8 +461,6 @@ func TestNewExporter_Zorkian(t *testing.T) { require.NoError(t, err) assert.Empty(t, server.MetadataChan) - cfg.HostMetadata.Enabled = true - cfg.HostMetadata.HostnameSource = HostnameSourceFirstResource testMetrics = pmetric.NewMetrics() testutil.TestMetrics.CopyTo(testMetrics) err = exp.ConsumeMetrics(context.Background(), testMetrics) From 46161c19f31f231dbcf4d74456b7a9a14b1f020e Mon Sep 17 00:00:00 2001 From: Jade Guiton Date: Fri, 6 Dec 2024 11:54:59 +0100 Subject: [PATCH 7/8] Refactor and add comments --- exporter/datadogexporter/factory.go | 33 +++++++------------- exporter/datadogexporter/logs_exporter.go | 2 +- exporter/datadogexporter/metrics_exporter.go | 2 +- exporter/datadogexporter/traces_exporter.go | 2 +- 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/exporter/datadogexporter/factory.go b/exporter/datadogexporter/factory.go index 87792285a408..85928c540761 100644 --- a/exporter/datadogexporter/factory.go +++ b/exporter/datadogexporter/factory.go @@ -270,13 +270,10 @@ func (f *factory) createMetricsExporter( statsv := set.BuildInfo.Command + set.BuildInfo.Version f.consumeStatsPayload(ctx, &wg, statsIn, statsWriter, statsv, acfg.AgentVersion, set.Logger) - // These variables are referenced below, but only used if HostMetadata.Enabled - var ( - pcfg hostmetadata.PusherConfig - metadataReporter *inframetadata.Reporter - ) + pcfg := newMetadataConfigfromConfig(cfg) + // Don't start a `Reporter` if host metadata is disabled. + var metadataReporter *inframetadata.Reporter if cfg.HostMetadata.Enabled { - pcfg = newMetadataConfigfromConfig(cfg) metadataReporter, err = f.Reporter(set, pcfg) if err != nil { cancel() @@ -284,7 +281,7 @@ func (f *factory) createMetricsExporter( } } - if cfg.OnlyMetadata { + if cfg.OnlyMetadata { // implies HostMetadata.Enabled pushMetricsFn = func(_ context.Context, md pmetric.Metrics) error { // only sending metadata use only metrics f.onceMetadata.Do(func() { @@ -382,13 +379,10 @@ func (f *factory) createTracesExporter( return nil, fmt.Errorf("failed to start trace-agent: %w", err) } - // These variables are referenced below, but only used if HostMetadata.Enabled - var ( - pcfg hostmetadata.PusherConfig - metadataReporter *inframetadata.Reporter - ) + pcfg := newMetadataConfigfromConfig(cfg) + // Don't start a `Reporter` if host metadata is disabled. + var metadataReporter *inframetadata.Reporter if cfg.HostMetadata.Enabled { - pcfg = newMetadataConfigfromConfig(cfg) metadataReporter, err = f.Reporter(set, pcfg) if err != nil { cancel() @@ -396,7 +390,7 @@ func (f *factory) createTracesExporter( } } - if cfg.OnlyMetadata { + if cfg.OnlyMetadata { // implies HostMetadata.Enabled // only host metadata needs to be sent, once. pusher = func(_ context.Context, td ptrace.Traces) error { f.onceMetadata.Do(func() { @@ -477,13 +471,10 @@ func (f *factory) createLogsExporter( ctx, cancel := context.WithCancel(ctx) // cancel() runs on shutdown - // These variables are referenced below, but only used if HostMetadata.Enabled - var ( - pcfg hostmetadata.PusherConfig - metadataReporter *inframetadata.Reporter - ) + pcfg := newMetadataConfigfromConfig(cfg) + // Don't start a `Reporter` if host metadata is disabled. + var metadataReporter *inframetadata.Reporter if cfg.HostMetadata.Enabled { - pcfg = newMetadataConfigfromConfig(cfg) metadataReporter, err = f.Reporter(set, pcfg) if err != nil { cancel() @@ -498,7 +489,7 @@ func (f *factory) createLogsExporter( } switch { - case cfg.OnlyMetadata: + case cfg.OnlyMetadata: // implies HostMetadata.Enabled // only host metadata needs to be sent, once. pusher = func(_ context.Context, td plog.Logs) error { f.onceMetadata.Do(func() { diff --git a/exporter/datadogexporter/logs_exporter.go b/exporter/datadogexporter/logs_exporter.go index 784db1572889..04776ab2c232 100644 --- a/exporter/datadogexporter/logs_exporter.go +++ b/exporter/datadogexporter/logs_exporter.go @@ -44,7 +44,7 @@ type logsExporter struct { sender *logs.Sender onceMetadata *sync.Once sourceProvider source.Provider - metadataReporter *inframetadata.Reporter + metadataReporter *inframetadata.Reporter // will be nil if host metadata is disabled } // newLogsExporter creates a new instance of logsExporter diff --git a/exporter/datadogexporter/metrics_exporter.go b/exporter/datadogexporter/metrics_exporter.go index ed2938e0a474..fc2cb6431114 100644 --- a/exporter/datadogexporter/metrics_exporter.go +++ b/exporter/datadogexporter/metrics_exporter.go @@ -56,7 +56,7 @@ type metricsExporter struct { retrier *clientutil.Retrier onceMetadata *sync.Once sourceProvider source.Provider - metadataReporter *inframetadata.Reporter + metadataReporter *inframetadata.Reporter // will be nil if host metadata is disabled // getPushTime returns a Unix time in nanoseconds, representing the time pushing metrics. // It will be overwritten in tests. getPushTime func() uint64 diff --git a/exporter/datadogexporter/traces_exporter.go b/exporter/datadogexporter/traces_exporter.go index a510c7e88ae4..7bdf88d55c1e 100644 --- a/exporter/datadogexporter/traces_exporter.go +++ b/exporter/datadogexporter/traces_exporter.go @@ -51,7 +51,7 @@ type traceExporter struct { onceMetadata *sync.Once // onceMetadata ensures that metadata is sent only once across all exporters agent *agent.Agent // agent processes incoming traces sourceProvider source.Provider // is able to source the origin of a trace (hostname, container, etc) - metadataReporter *inframetadata.Reporter // reports host metadata from resource attributes and metrics + metadataReporter *inframetadata.Reporter // reports host metadata from resource attributes and metrics (will be nil if host metadata is disabled) retrier *clientutil.Retrier // retrier handles retries on requests } From 639ce641165d971dc12c35f002b973c49cd00e83 Mon Sep 17 00:00:00 2001 From: Jade Guiton Date: Fri, 6 Dec 2024 12:53:47 +0100 Subject: [PATCH 8/8] Minify diff --- exporter/datadogexporter/factory.go | 7 +++---- exporter/datadogexporter/logs_exporter.go | 2 +- exporter/datadogexporter/metrics_exporter.go | 2 +- exporter/datadogexporter/metrics_exporter_test.go | 6 ++---- exporter/datadogexporter/traces_exporter.go | 2 +- 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/exporter/datadogexporter/factory.go b/exporter/datadogexporter/factory.go index 85928c540761..5726d889d403 100644 --- a/exporter/datadogexporter/factory.go +++ b/exporter/datadogexporter/factory.go @@ -269,7 +269,6 @@ func (f *factory) createMetricsExporter( statsIn := make(chan []byte, 1000) statsv := set.BuildInfo.Command + set.BuildInfo.Version f.consumeStatsPayload(ctx, &wg, statsIn, statsWriter, statsv, acfg.AgentVersion, set.Logger) - pcfg := newMetadataConfigfromConfig(cfg) // Don't start a `Reporter` if host metadata is disabled. var metadataReporter *inframetadata.Reporter @@ -281,7 +280,7 @@ func (f *factory) createMetricsExporter( } } - if cfg.OnlyMetadata { // implies HostMetadata.Enabled + if cfg.OnlyMetadata { pushMetricsFn = func(_ context.Context, md pmetric.Metrics) error { // only sending metadata use only metrics f.onceMetadata.Do(func() { @@ -390,7 +389,7 @@ func (f *factory) createTracesExporter( } } - if cfg.OnlyMetadata { // implies HostMetadata.Enabled + if cfg.OnlyMetadata { // only host metadata needs to be sent, once. pusher = func(_ context.Context, td ptrace.Traces) error { f.onceMetadata.Do(func() { @@ -489,7 +488,7 @@ func (f *factory) createLogsExporter( } switch { - case cfg.OnlyMetadata: // implies HostMetadata.Enabled + case cfg.OnlyMetadata: // only host metadata needs to be sent, once. pusher = func(_ context.Context, td plog.Logs) error { f.onceMetadata.Do(func() { diff --git a/exporter/datadogexporter/logs_exporter.go b/exporter/datadogexporter/logs_exporter.go index 04776ab2c232..784db1572889 100644 --- a/exporter/datadogexporter/logs_exporter.go +++ b/exporter/datadogexporter/logs_exporter.go @@ -44,7 +44,7 @@ type logsExporter struct { sender *logs.Sender onceMetadata *sync.Once sourceProvider source.Provider - metadataReporter *inframetadata.Reporter // will be nil if host metadata is disabled + metadataReporter *inframetadata.Reporter } // newLogsExporter creates a new instance of logsExporter diff --git a/exporter/datadogexporter/metrics_exporter.go b/exporter/datadogexporter/metrics_exporter.go index fc2cb6431114..ed2938e0a474 100644 --- a/exporter/datadogexporter/metrics_exporter.go +++ b/exporter/datadogexporter/metrics_exporter.go @@ -56,7 +56,7 @@ type metricsExporter struct { retrier *clientutil.Retrier onceMetadata *sync.Once sourceProvider source.Provider - metadataReporter *inframetadata.Reporter // will be nil if host metadata is disabled + metadataReporter *inframetadata.Reporter // getPushTime returns a Unix time in nanoseconds, representing the time pushing metrics. // It will be overwritten in tests. getPushTime func() uint64 diff --git a/exporter/datadogexporter/metrics_exporter_test.go b/exporter/datadogexporter/metrics_exporter_test.go index 33dd4ddbf830..95935fd053a4 100644 --- a/exporter/datadogexporter/metrics_exporter_test.go +++ b/exporter/datadogexporter/metrics_exporter_test.go @@ -31,8 +31,6 @@ import ( conventions127 "go.opentelemetry.io/collector/semconv/v1.27.0" conventions "go.opentelemetry.io/collector/semconv/v1.6.1" "go.uber.org/zap" - - "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/datadog/config" ) func TestNewExporter(t *testing.T) { @@ -60,7 +58,7 @@ func TestNewExporter(t *testing.T) { CumulativeMonotonicMode: CumulativeMonotonicSumModeToDelta, }, }, - HostMetadata: config.HostMetadataConfig{ + HostMetadata: HostMetadataConfig{ Enabled: true, ReporterPeriod: 30 * time.Minute, HostnameSource: HostnameSourceFirstResource, @@ -442,7 +440,7 @@ func TestNewExporter_Zorkian(t *testing.T) { CumulativeMonotonicMode: CumulativeMonotonicSumModeToDelta, }, }, - HostMetadata: config.HostMetadataConfig{ + HostMetadata: HostMetadataConfig{ Enabled: true, ReporterPeriod: 30 * time.Minute, HostnameSource: HostnameSourceFirstResource, diff --git a/exporter/datadogexporter/traces_exporter.go b/exporter/datadogexporter/traces_exporter.go index 7bdf88d55c1e..a510c7e88ae4 100644 --- a/exporter/datadogexporter/traces_exporter.go +++ b/exporter/datadogexporter/traces_exporter.go @@ -51,7 +51,7 @@ type traceExporter struct { onceMetadata *sync.Once // onceMetadata ensures that metadata is sent only once across all exporters agent *agent.Agent // agent processes incoming traces sourceProvider source.Provider // is able to source the origin of a trace (hostname, container, etc) - metadataReporter *inframetadata.Reporter // reports host metadata from resource attributes and metrics (will be nil if host metadata is disabled) + metadataReporter *inframetadata.Reporter // reports host metadata from resource attributes and metrics retrier *clientutil.Retrier // retrier handles retries on requests }