From 6acded15003d0c90abe97315435ef4aa1f33eaab Mon Sep 17 00:00:00 2001 From: Gustavo Caso Date: Thu, 28 Nov 2024 17:22:49 +0100 Subject: [PATCH] propagate the tagger component when building the OTLP pipeline for serverless-init --- cmd/serverless-init/main.go | 6 +++--- pkg/serverless/otlp/otlp.go | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/serverless-init/main.go b/cmd/serverless-init/main.go index 1b5242fa41e213..b4e2076350ff5b 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/pkg/serverless/otlp/otlp.go b/pkg/serverless/otlp/otlp.go index fcb44c14d3c472..4f5587904dc964 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" pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup" "github.com/DataDog/datadog-agent/pkg/serializer" @@ -28,8 +29,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