diff --git a/cmd/serverless-init/main.go b/cmd/serverless-init/main.go index 1b5242fa41e21..b4e2076350ff5 100644 --- a/cmd/serverless-init/main.go +++ b/cmd/serverless-init/main.go @@ -146,7 +146,7 @@ func setup(_ mode.Conf, tagger tagger.Component) (cloudservice.CloudService, *se metricAgent := setupMetricAgent(tags, tagger) metric.AddColdStartMetric(prefix, metricAgent.GetExtraTags(), time.Now(), metricAgent.Demux) - setupOtlpAgent(metricAgent) + setupOtlpAgent(metricAgent, tagger) go flushMetricsAgent(metricAgent) return cloudService, agentLogConfig, traceAgent, metricAgent, logsAgent @@ -200,12 +200,12 @@ func setupMetricAgent(tags map[string]string, tagger tagger.Component) *metrics. return metricAgent } -func setupOtlpAgent(metricAgent *metrics.ServerlessMetricAgent) { +func setupOtlpAgent(metricAgent *metrics.ServerlessMetricAgent, tagger tagger.Component) { if !otlp.IsEnabled() { log.Debugf("otlp endpoint disabled") return } - otlpAgent := otlp.NewServerlessOTLPAgent(metricAgent.Demux.Serializer()) + otlpAgent := otlp.NewServerlessOTLPAgent(metricAgent.Demux.Serializer(), tagger) otlpAgent.Start() } diff --git a/cmd/serverless/main.go b/cmd/serverless/main.go index 77f46c01fded4..a679ceef10181 100644 --- a/cmd/serverless/main.go +++ b/cmd/serverless/main.go @@ -124,7 +124,7 @@ func runAgent(tagger tagger.Component) { wg.Add(3) go startTraceAgent(&wg, lambdaSpanChan, coldStartSpanId, serverlessDaemon, tagger, rcService) - go startOtlpAgent(&wg, metricAgent, serverlessDaemon) + go startOtlpAgent(&wg, metricAgent, serverlessDaemon, tagger) go startTelemetryCollection(&wg, serverlessID, logChannel, serverlessDaemon, tagger) // start appsec @@ -330,13 +330,13 @@ func startTelemetryCollection(wg *sync.WaitGroup, serverlessID registration.ID, } } -func startOtlpAgent(wg *sync.WaitGroup, metricAgent *metrics.ServerlessMetricAgent, serverlessDaemon *daemon.Daemon) { +func startOtlpAgent(wg *sync.WaitGroup, metricAgent *metrics.ServerlessMetricAgent, serverlessDaemon *daemon.Daemon, tagger tagger.Component) { defer wg.Done() if !otlp.IsEnabled() { log.Debug("otlp endpoint disabled") return } - otlpAgent := otlp.NewServerlessOTLPAgent(metricAgent.Demux.Serializer()) + otlpAgent := otlp.NewServerlessOTLPAgent(metricAgent.Demux.Serializer(), tagger) otlpAgent.Start() serverlessDaemon.SetOTLPAgent(otlpAgent) diff --git a/pkg/serverless/otlp/otlp.go b/pkg/serverless/otlp/otlp.go index 0efb26bb4f23c..19f7c7847111e 100644 --- a/pkg/serverless/otlp/otlp.go +++ b/pkg/serverless/otlp/otlp.go @@ -15,6 +15,7 @@ import ( "go.opentelemetry.io/collector/otelcol" + tagger "github.com/DataDog/datadog-agent/comp/core/tagger/def" coreOtlp "github.com/DataDog/datadog-agent/comp/otelcol/otlp" "github.com/DataDog/datadog-agent/comp/otelcol/otlp/configcheck" pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup" @@ -29,8 +30,8 @@ type ServerlessOTLPAgent struct { // NewServerlessOTLPAgent creates a new ServerlessOTLPAgent with the correct // otel pipeline. -func NewServerlessOTLPAgent(serializer serializer.MetricSerializer) *ServerlessOTLPAgent { - pipeline, err := coreOtlp.NewPipelineFromAgentConfig(pkgconfigsetup.Datadog(), serializer, nil, nil) +func NewServerlessOTLPAgent(serializer serializer.MetricSerializer, tagger tagger.Component) *ServerlessOTLPAgent { + pipeline, err := coreOtlp.NewPipelineFromAgentConfig(pkgconfigsetup.Datadog(), serializer, nil, tagger) if err != nil { log.Error("Error creating new otlp pipeline:", err) return nil diff --git a/pkg/serverless/otlp/otlp_no_otlp.go b/pkg/serverless/otlp/otlp_no_otlp.go index 761639bed48b0..fe953d1a75543 100644 --- a/pkg/serverless/otlp/otlp_no_otlp.go +++ b/pkg/serverless/otlp/otlp_no_otlp.go @@ -8,13 +8,16 @@ //nolint:revive // TODO(SERV) Fix revive linter package otlp -import "github.com/DataDog/datadog-agent/pkg/serializer" +import ( + tagger "github.com/DataDog/datadog-agent/comp/core/tagger/def" + "github.com/DataDog/datadog-agent/pkg/serializer" +) //nolint:revive // TODO(SERV) Fix revive linter type ServerlessOTLPAgent struct{} //nolint:revive // TODO(SERV) Fix revive linter -func NewServerlessOTLPAgent(serializer.MetricSerializer) *ServerlessOTLPAgent { +func NewServerlessOTLPAgent(serializer.MetricSerializer, tagger.Component) *ServerlessOTLPAgent { return nil } diff --git a/pkg/serverless/otlp/otlp_test.go b/pkg/serverless/otlp/otlp_test.go index b7851f4488e14..e7481a198b433 100644 --- a/pkg/serverless/otlp/otlp_test.go +++ b/pkg/serverless/otlp/otlp_test.go @@ -21,11 +21,13 @@ import ( "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp" sdktrace "go.opentelemetry.io/otel/sdk/trace" + "github.com/stretchr/testify/assert" + + taggernoop "github.com/DataDog/datadog-agent/comp/core/tagger/impl-noop" pb "github.com/DataDog/datadog-agent/pkg/proto/pbgo/trace" "github.com/DataDog/datadog-agent/pkg/serverless/metrics" "github.com/DataDog/datadog-agent/pkg/serverless/trace" "github.com/DataDog/datadog-agent/pkg/trace/testutil" - "github.com/stretchr/testify/assert" ) func TestMain(m *testing.M) { @@ -84,7 +86,7 @@ func TestServerlessOTLPAgentReceivesTraces(t *testing.T) { assert.True(metricAgent.IsReady()) // setup otlp agent - otlpAgent := NewServerlessOTLPAgent(metricAgent.Demux.Serializer()) + otlpAgent := NewServerlessOTLPAgent(metricAgent.Demux.Serializer(), taggernoop.NewComponent()) otlpAgent.Start() defer otlpAgent.Stop() assert.NotNil(otlpAgent.pipeline)