Skip to content

Commit

Permalink
propagate the tagger component when building the OTLP pipeline for se…
Browse files Browse the repository at this point in the history
…rverless-init
  • Loading branch information
GustavoCaso committed Nov 28, 2024
1 parent 7bf22e7 commit 6acded1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions cmd/serverless-init/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}

Expand Down
5 changes: 3 additions & 2 deletions pkg/serverless/otlp/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down

0 comments on commit 6acded1

Please sign in to comment.