Skip to content

Commit

Permalink
[mq] working branch - merge b9923bb on top of main at 73745b4
Browse files Browse the repository at this point in the history
{"baseBranch":"main","baseCommit":"73745b456a0b3c1475e5c86b2a3d8782c8853543","createdAt":"2025-01-24T21:59:39.000270Z","headSha":"b9923bb0e2ceb417ad6b7f03da4f629dfccaa978","id":"2549fe2a-fa78-4a0e-85da-e46ef8101a71","priority":"200","pullRequestNumber":"33332","queuedAt":"2025-01-24T21:59:38.997184Z","status":"STATUS_QUEUED"}
  • Loading branch information
dd-mergequeue[bot] authored Jan 24, 2025
2 parents cfc57df + b9923bb commit cec2062
Show file tree
Hide file tree
Showing 16 changed files with 93 additions and 92 deletions.
2 changes: 1 addition & 1 deletion cmd/otel-agent/config/agent_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func NewConfigComponent(ctx context.Context, ddCfg string, uris []string) (confi
}

if pkgconfig.Get("apm_config.features") == nil {
apmConfigFeatures := []string{"enable_receive_resource_spans_v2"}
apmConfigFeatures := []string{}
if pkgdatadog.OperationAndResourceNameV2FeatureGate.IsEnabled() {
apmConfigFeatures = append(apmConfigFeatures, "enable_operation_and_resource_name_logic_v2")
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/otel-agent/config/agent_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (suite *ConfigTestSuite) TestAgentConfig() {
assert.Equal(t, false, c.Get("apm_config.receiver_enabled"))
assert.Equal(t, 10, c.Get("apm_config.trace_buffer"))
assert.Equal(t, false, c.Get("otlp_config.traces.span_name_as_resource_name"))
assert.Equal(t, []string{"enable_receive_resource_spans_v2"}, c.Get("apm_config.features"))
assert.Equal(t, []string{}, c.Get("apm_config.features"))
}

func (suite *ConfigTestSuite) TestAgentConfigDefaults() {
Expand All @@ -80,7 +80,7 @@ func (suite *ConfigTestSuite) TestAgentConfigDefaults() {
assert.Equal(t, "https://trace.agent.datadoghq.com", c.Get("apm_config.apm_dd_url"))
assert.Equal(t, false, c.Get("apm_config.receiver_enabled"))
assert.Equal(t, false, c.Get("otlp_config.traces.span_name_as_resource_name"))
assert.Equal(t, []string{"enable_receive_resource_spans_v2", "enable_otlp_compute_top_level_by_span_kind"},
assert.Equal(t, []string{"enable_otlp_compute_top_level_by_span_kind"},
c.Get("apm_config.features"))
}

Expand All @@ -104,7 +104,7 @@ func (suite *ConfigTestSuite) TestOperationAndResourceNameV2FeatureGate() {
assert.Equal(t, "https://trace.agent.datadoghq.com", c.Get("apm_config.apm_dd_url"))
assert.Equal(t, false, c.Get("apm_config.receiver_enabled"))
assert.Equal(t, false, c.Get("otlp_config.traces.span_name_as_resource_name"))
assert.Equal(t, []string{"enable_receive_resource_spans_v2", "enable_operation_and_resource_name_logic_v2", "enable_otlp_compute_top_level_by_span_kind"},
assert.Equal(t, []string{"enable_operation_and_resource_name_logic_v2", "enable_otlp_compute_top_level_by_span_kind"},
c.Get("apm_config.features"))
}

Expand Down Expand Up @@ -152,7 +152,7 @@ func (suite *ConfigTestSuite) TestAgentConfigWithDatadogYamlDefaults() {
assert.Equal(t, "https://trace.agent.datadoghq.com", c.Get("apm_config.apm_dd_url"))
assert.Equal(t, false, c.Get("apm_config.receiver_enabled"))
assert.Equal(t, false, c.Get("otlp_config.traces.span_name_as_resource_name"))
assert.Equal(t, []string{"enable_receive_resource_spans_v2", "enable_otlp_compute_top_level_by_span_kind"}, c.Get("apm_config.features"))
assert.Equal(t, []string{"enable_otlp_compute_top_level_by_span_kind"}, c.Get("apm_config.features"))

// log_level from datadog.yaml takes precedence -> more verbose
assert.Equal(t, "debug", c.Get("log_level"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ func testTraceExporter(enableReceiveResourceSpansV2 bool, t *testing.T) {
tcfg.TraceWriter.FlushPeriodSeconds = 0.1
tcfg.Endpoints[0].APIKey = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
tcfg.Endpoints[0].Host = server.URL
if enableReceiveResourceSpansV2 {
tcfg.Features["enable_receive_resource_spans_v2"] = struct{}{}
if !enableReceiveResourceSpansV2 {
tcfg.Features["disable_receive_resource_spans_v2"] = struct{}{}
}
ctx := context.Background()
traceagent := pkgagent.NewAgent(ctx, tcfg, telemetry.NewNoopCollector(), &ddgostatsd.NoOpClient{}, gzip.NewComponent())
Expand Down Expand Up @@ -132,8 +132,8 @@ func testNewTracesExporter(enableReceiveResourceSpansV2 bool, t *testing.T) {
tcfg.Endpoints[0].APIKey = "ddog_32_characters_long_api_key1"
ctx := context.Background()
tcfg.ReceiverEnabled = false
if enableReceiveResourceSpansV2 {
tcfg.Features["enable_receive_resource_spans_v2"] = struct{}{}
if !enableReceiveResourceSpansV2 {
tcfg.Features["disable_receive_resource_spans_v2"] = struct{}{}
}
traceagent := pkgagent.NewAgent(ctx, tcfg, telemetry.NewNoopCollector(), &ddgostatsd.NoOpClient{}, gzip.NewComponent())

Expand Down
4 changes: 2 additions & 2 deletions comp/otelcol/otlp/components/statsprocessor/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ func testTraceAgent(enableReceiveResourceSpansV2 bool, t *testing.T) {
require.NoError(t, err)
cfg.OTLPReceiver.AttributesTranslator = attributesTranslator
cfg.BucketInterval = 50 * time.Millisecond
if enableReceiveResourceSpansV2 {
cfg.Features["enable_receive_resource_spans_v2"] = struct{}{}
if !enableReceiveResourceSpansV2 {
cfg.Features["disable_receive_resource_spans_v2"] = struct{}{}
}
cfg.Features["enable_operation_and_resource_name_logic_v2"] = struct{}{}
out := make(chan *pb.StatsPayload, 10)
Expand Down
12 changes: 6 additions & 6 deletions pkg/trace/api/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ func NewOTLPReceiver(out chan<- *Payload, cfg *config.AgentConfig, statsd statsd
ignoreResNames[resName] = struct{}{}
}
_ = statsd.Gauge("datadog.trace_agent.otlp.compute_top_level_by_span_kind", computeTopLevelBySpanKindVal, nil, 1)
enableReceiveResourceSpansV2Val := 0.0
if cfg.HasFeature("enable_receive_resource_spans_v2") {
enableReceiveResourceSpansV2Val = 1.0
enableReceiveResourceSpansV2Val := 1.0
if cfg.HasFeature("disable_receive_resource_spans_v2") {
enableReceiveResourceSpansV2Val = 0.0
}
_ = statsd.Gauge("datadog.trace_agent.otlp.enable_receive_resource_spans_v2", enableReceiveResourceSpansV2Val, nil, 1)
return &OTLPReceiver{out: out, conf: cfg, cidProvider: NewIDProvider(cfg.ContainerProcRoot, cfg.ContainerIDFromOriginInfo), statsd: statsd, timing: timing, ignoreResNames: ignoreResNames}
Expand Down Expand Up @@ -227,10 +227,10 @@ func (o *OTLPReceiver) SetOTelAttributeTranslator(attrstrans *attributes.Transla

// ReceiveResourceSpans processes the given rspans and returns the source that it identified from processing them.
func (o *OTLPReceiver) ReceiveResourceSpans(ctx context.Context, rspans ptrace.ResourceSpans, httpHeader http.Header) source.Source {
if o.conf.HasFeature("enable_receive_resource_spans_v2") {
return o.receiveResourceSpansV2(ctx, rspans, isHeaderTrue(header.ComputedStats, httpHeader.Get(header.ComputedStats)))
if o.conf.HasFeature("disable_receive_resource_spans_v2") {
return o.receiveResourceSpansV1(ctx, rspans, httpHeader)
}
return o.receiveResourceSpansV1(ctx, rspans, httpHeader)
return o.receiveResourceSpansV2(ctx, rspans, isHeaderTrue(header.ComputedStats, httpHeader.Get(header.ComputedStats)))
}

func (o *OTLPReceiver) receiveResourceSpansV2(ctx context.Context, rspans ptrace.ResourceSpans, clientComputedStats bool) source.Source {
Expand Down
55 changes: 26 additions & 29 deletions pkg/trace/api/otlp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ func TestOTLPMetrics(t *testing.T) {
func testOTLPMetrics(enableReceiveResourceSpansV2 bool, t *testing.T) {
assert := assert.New(t)
cfg := NewTestConfig(t)
if enableReceiveResourceSpansV2 {
cfg.Features["enable_receive_resource_spans_v2"] = struct{}{}
if !enableReceiveResourceSpansV2 {
cfg.Features["disable_receive_resource_spans_v2"] = struct{}{}
}
stats := &teststatsd.Client{}

Expand Down Expand Up @@ -231,8 +231,8 @@ func testOTLPNameRemapping(enableReceiveResourceSpansV2 bool, t *testing.T) {
// Verify that while EnableOperationAndResourceNamesV2 is in alpha, SpanNameRemappings overrides it
cfg := NewTestConfig(t)
cfg.Features["enable_operation_and_resource_name_logic_v2"] = struct{}{}
if enableReceiveResourceSpansV2 {
cfg.Features["enable_receive_resource_spans_v2"] = struct{}{}
if !enableReceiveResourceSpansV2 {
cfg.Features["disable_receive_resource_spans_v2"] = struct{}{}
}
cfg.OTLPReceiver.SpanNameRemappings = map[string]string{"libname.unspecified": "new"}
out := make(chan *Payload, 1)
Expand Down Expand Up @@ -269,8 +269,8 @@ func TestOTLPSpanNameV2(t *testing.T) {
func testOTLPSpanNameV2(enableReceiveResourceSpansV2 bool, t *testing.T) {
cfg := NewTestConfig(t)
cfg.Features["enable_operation_and_resource_name_logic_v2"] = struct{}{}
if enableReceiveResourceSpansV2 {
cfg.Features["enable_receive_resource_spans_v2"] = struct{}{}
if !enableReceiveResourceSpansV2 {
cfg.Features["disable_receive_resource_spans_v2"] = struct{}{}
}
out := make(chan *Payload, 1)
rcv := NewOTLPReceiver(out, cfg, &statsd.NoOpClient{}, &timing.NoopReporter{})
Expand Down Expand Up @@ -708,8 +708,8 @@ func TestCreateChunks(t *testing.T) {

func testCreateChunk(enableReceiveResourceSpansV2 bool, t *testing.T) {
cfg := NewTestConfig(t)
if enableReceiveResourceSpansV2 {
cfg.Features["enable_receive_resource_spans_v2"] = struct{}{}
if !enableReceiveResourceSpansV2 {
cfg.Features["disable_receive_resource_spans_v2"] = struct{}{}
}
cfg.OTLPReceiver.ProbabilisticSampling = 50
o := NewOTLPReceiver(nil, cfg, &statsd.NoOpClient{}, &timing.NoopReporter{})
Expand Down Expand Up @@ -763,8 +763,8 @@ func TestOTLPReceiveResourceSpans(t *testing.T) {

func testOTLPReceiveResourceSpans(enableReceiveResourceSpansV2 bool, t *testing.T) {
cfg := NewTestConfig(t)
if enableReceiveResourceSpansV2 {
cfg.Features["enable_receive_resource_spans_v2"] = struct{}{}
if !enableReceiveResourceSpansV2 {
cfg.Features["disable_receive_resource_spans_v2"] = struct{}{}
}
out := make(chan *Payload, 1)
rcv := NewOTLPReceiver(out, cfg, &statsd.NoOpClient{}, &timing.NoopReporter{})
Expand Down Expand Up @@ -1260,8 +1260,8 @@ func testOTLPHostname(enableReceiveResourceSpansV2 bool, t *testing.T) {
}
for _, tt := range testcases {
cfg := NewTestConfig(t)
if enableReceiveResourceSpansV2 {
cfg.Features["enable_receive_resource_spans_v2"] = struct{}{}
if !enableReceiveResourceSpansV2 {
cfg.Features["disable_receive_resource_spans_v2"] = struct{}{}
}
cfg.Hostname = tt.config
out := make(chan *Payload, 1)
Expand Down Expand Up @@ -1296,7 +1296,6 @@ func testOTLPHostname(enableReceiveResourceSpansV2 bool, t *testing.T) {

func TestResourceRelatedSpanAttributesAreIgnored_ReceiveResourceSpansV2(t *testing.T) {
cfg := NewTestConfig(t)
cfg.Features["enable_receive_resource_spans_v2"] = struct{}{}
out := make(chan *Payload, 1)
rcv := NewOTLPReceiver(out, cfg, &statsd.NoOpClient{}, &timing.NoopReporter{})
rattr := map[string]interface{}{}
Expand Down Expand Up @@ -1343,16 +1342,16 @@ func TestOTLPReceiver(t *testing.T) {
func testOTLPReceiver(enableReceiveResourceSpansV2 bool, t *testing.T) {
t.Run("New", func(t *testing.T) {
cfg := NewTestConfig(t)
if enableReceiveResourceSpansV2 {
cfg.Features["enable_receive_resource_spans_v2"] = struct{}{}
if !enableReceiveResourceSpansV2 {
cfg.Features["disable_receive_resource_spans_v2"] = struct{}{}
}
assert.NotNil(t, NewOTLPReceiver(nil, cfg, &statsd.NoOpClient{}, &timing.NoopReporter{}).conf)
})

t.Run("Start/nil", func(t *testing.T) {
cfg := NewTestConfig(t)
if enableReceiveResourceSpansV2 {
cfg.Features["enable_receive_resource_spans_v2"] = struct{}{}
if !enableReceiveResourceSpansV2 {
cfg.Features["disable_receive_resource_spans_v2"] = struct{}{}
}
o := NewOTLPReceiver(nil, cfg, &statsd.NoOpClient{}, &timing.NoopReporter{})
o.Start()
Expand All @@ -1363,8 +1362,8 @@ func testOTLPReceiver(enableReceiveResourceSpansV2 bool, t *testing.T) {
t.Run("Start/grpc", func(t *testing.T) {
port := testutil.FreeTCPPort(t)
cfg := NewTestConfig(t)
if enableReceiveResourceSpansV2 {
cfg.Features["enable_receive_resource_spans_v2"] = struct{}{}
if !enableReceiveResourceSpansV2 {
cfg.Features["disable_receive_resource_spans_v2"] = struct{}{}
}
cfg.OTLPReceiver = &config.OTLP{
BindHost: "localhost",
Expand All @@ -1384,8 +1383,8 @@ func testOTLPReceiver(enableReceiveResourceSpansV2 bool, t *testing.T) {
t.Run("processRequest", func(t *testing.T) {
out := make(chan *Payload, 5)
cfg := NewTestConfig(t)
if enableReceiveResourceSpansV2 {
cfg.Features["enable_receive_resource_spans_v2"] = struct{}{}
if !enableReceiveResourceSpansV2 {
cfg.Features["disable_receive_resource_spans_v2"] = struct{}{}
}
o := NewOTLPReceiver(out, cfg, &statsd.NoOpClient{}, &timing.NoopReporter{})
o.processRequest(context.Background(), http.Header(map[string][]string{
Expand Down Expand Up @@ -1627,7 +1626,6 @@ func TestOTelSpanToDDSpan(t *testing.T) {
func testOTelSpanToDDSpan(enableOperationAndResourceNameV2 bool, t *testing.T) {
cfg := NewTestConfig(t)
now := uint64(otlpTestSpan.StartTimestamp())
cfg.Features["enable_receive_resource_spans_v2"] = struct{}{}
if enableOperationAndResourceNameV2 {
cfg.Features["enable_operation_and_resource_name_logic_v2"] = struct{}{}
}
Expand Down Expand Up @@ -3410,7 +3408,6 @@ func testOTLPConvertSpanSetPeerService(enableOperationAndResourceNameV2 bool, t
func testOTelSpanToDDSpanSetPeerService(enableOperationAndResourceNameV2 bool, t *testing.T) {
now := uint64(otlpTestSpan.StartTimestamp())
cfg := NewTestConfig(t)
cfg.Features["enable_receive_resource_spans_v2"] = struct{}{}
if enableOperationAndResourceNameV2 {
cfg.Features["enable_operation_and_resource_name_logic_v2"] = struct{}{}
}
Expand Down Expand Up @@ -3795,8 +3792,8 @@ func testResourceAttributesMap(enableReceiveResourceSpansV2 bool, t *testing.T)
lib := pcommon.NewInstrumentationScope()
span := testutil.NewOTLPSpan(&testutil.OTLPSpan{})
cfg := NewTestConfig(t)
if enableReceiveResourceSpansV2 {
cfg.Features["enable_receive_resource_spans_v2"] = struct{}{}
if !enableReceiveResourceSpansV2 {
cfg.Features["disable_receive_resource_spans_v2"] = struct{}{}
}
NewOTLPReceiver(nil, cfg, &statsd.NoOpClient{}, &timing.NoopReporter{}).convertSpan(rattr, lib, span)
assert.Len(t, rattr, 1) // ensure "rattr" has no new entries
Expand Down Expand Up @@ -4273,8 +4270,8 @@ func benchmarkProcessRequest(enableReceiveResourceSpansV2 bool, b *testing.B) {
}()

cfg := NewBenchmarkTestConfig(b)
if enableReceiveResourceSpansV2 {
cfg.Features["enable_receive_resource_spans_v2"] = struct{}{}
if !enableReceiveResourceSpansV2 {
cfg.Features["disable_receive_resource_spans_v2"] = struct{}{}
}
r := NewOTLPReceiver(out, cfg, &statsd.NoOpClient{}, &timing.NoopReporter{})
b.ReportAllocs()
Expand Down Expand Up @@ -4316,8 +4313,8 @@ func benchmarkProcessRequestTopLevel(enableReceiveResourceSpansV2 bool, b *testi
}()

cfg := NewBenchmarkTestConfig(b)
if enableReceiveResourceSpansV2 {
cfg.Features["enable_receive_resource_spans_v2"] = struct{}{}
if !enableReceiveResourceSpansV2 {
cfg.Features["disable_receive_resource_spans_v2"] = struct{}{}
}
cfg.Features["enable_otlp_compute_top_level_by_span_kind"] = struct{}{}
r := NewOTLPReceiver(out, cfg, &statsd.NoOpClient{}, &timing.NoopReporter{})
Expand Down
63 changes: 31 additions & 32 deletions pkg/trace/stats/otel_benckmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,37 +45,37 @@ func benchmarkOTelObfuscation(b *testing.B, enableObfuscation bool) {
semconv.AttributeDeploymentEnvironment: "tracer_env",
semconv.AttributeDBSystem: "mysql",
semconv.AttributeDBStatement: `
SELECT
u.id,
u.name,
u.email,
o.order_id,
o.total_amount,
p.product_name,
p.price
FROM
users u
JOIN
orders o ON u.id = o.user_id
JOIN
order_items oi ON o.order_id = oi.order_id
JOIN
products p ON oi.product_id = p.product_id
WHERE
u.status = 'active'
AND o.order_date BETWEEN '2023-01-01' AND '2023-12-31'
AND p.category IN ('electronics', 'books')
GROUP BY
u.id,
u.name,
u.email,
o.order_id,
o.total_amount,
p.product_name,
p.price
ORDER BY
o.order_date DESC,
p.price ASC
SELECT
u.id,
u.name,
u.email,
o.order_id,
o.total_amount,
p.product_name,
p.price
FROM
users u
JOIN
orders o ON u.id = o.user_id
JOIN
order_items oi ON o.order_id = oi.order_id
JOIN
products p ON oi.product_id = p.product_id
WHERE
u.status = 'active'
AND o.order_date BETWEEN '2023-01-01' AND '2023-12-31'
AND p.category IN ('electronics', 'books')
GROUP BY
u.id,
u.name,
u.email,
o.order_id,
o.total_amount,
p.product_name,
p.price
ORDER BY
o.order_date DESC,
p.price ASC
LIMIT 100;
`,
} {
Expand All @@ -94,7 +94,6 @@ func benchmarkOTelObfuscation(b *testing.B, enableObfuscation bool) {
conf.Hostname = "agent_host"
conf.DefaultEnv = "agent_env"
conf.Obfuscation.Redis.Enabled = true
conf.Features["enable_receive_resource_spans_v2"] = struct{}{}
conf.Features["enable_operation_and_resource_name_logic_v2"] = struct{}{}
conf.OTLPReceiver.AttributesTranslator = attributesTranslator

Expand Down
4 changes: 2 additions & 2 deletions pkg/trace/stats/otel_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ func TestProcessOTLPTraces(t *testing.T) {
conf.Hostname = agentHost
conf.DefaultEnv = agentEnv
conf.Features["enable_cid_stats"] = struct{}{}
if tt.enableReceiveResourceSpansV2 {
conf.Features["enable_receive_resource_spans_v2"] = struct{}{}
if !tt.enableReceiveResourceSpansV2 {
conf.Features["disable_receive_resource_spans_v2"] = struct{}{}
}
conf.PeerTagsAggregation = tt.peerTagsAggr
conf.OTLPReceiver.AttributesTranslator = attributesTranslator
Expand Down
4 changes: 2 additions & 2 deletions pkg/trace/stats/oteltest/otel_apm_stats_comparison_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ func testOTelAPMStatsMatch(enableReceiveResourceSpansV2 bool, t *testing.T) {
require.NoError(t, err)
tcfg := getTraceAgentCfg(attributesTranslator)
peerTagKeys := tcfg.ConfiguredPeerTags()
if enableReceiveResourceSpansV2 {
tcfg.Features["enable_receive_resource_spans_v2"] = struct{}{}
if !enableReceiveResourceSpansV2 {
tcfg.Features["disable_receive_resource_spans_v2"] = struct{}{}
}

metricsClient := &statsd.NoOpClient{}
Expand Down
6 changes: 3 additions & 3 deletions pkg/trace/transform/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ func OtelSpanToDDSpanMinimal(

// correct span type logic if using new resource receiver, keep same if on v1. separate from OperationAndResourceNameV2Enabled.
var spanType string
if conf.HasFeature("enable_receive_resource_spans_v2") {
spanType = traceutil.GetOTelSpanType(otelspan, otelres)
} else {
if conf.HasFeature("disable_receive_resource_spans_v2") {
spanType = traceutil.GetOTelAttrValInResAndSpanAttrs(otelspan, otelres, true, "span.type")
if spanType == "" {
spanType = traceutil.SpanKind2Type(otelspan, otelres)
}
} else {
spanType = traceutil.GetOTelSpanType(otelspan, otelres)
}

ddspan := &pb.Span{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

---
enhancements:
- |
Added a new feature flag `disable_receive_resource_spans_v2` in DD_APM_FEATURES that replaces `enable_receive_resource_spans_v2` - the refactored implementation of ReceiveResourceSpans for OTLP is now opt-out instead of opt-in.
Loading

0 comments on commit cec2062

Please sign in to comment.