Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ASCII-2567] propagate the tagger component when building the OTLP pipeline for serverless-init #31576

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 3 additions & 3 deletions cmd/serverless/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

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"
"github.com/DataDog/datadog-agent/comp/otelcol/otlp/configcheck"
pkgconfigsetup "github.com/DataDog/datadog-agent/pkg/config/setup"
Expand All @@ -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
Expand Down
7 changes: 5 additions & 2 deletions pkg/serverless/otlp/otlp_no_otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
6 changes: 4 additions & 2 deletions pkg/serverless/otlp/otlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down
Loading