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

Add feature gate for refactor of OTLP->Datadog span translation #37171

Merged
Show file tree
Hide file tree
Changes from 7 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: datadogexporter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Add a feature gate datadog.EnableReceiveResourceSpansV2. Enabling this gate uses a refactored implementation of OTLP->Datadog Span translation in datadogexporter and datadogconnector which improves performance by 10%, and deprecates the following functionality:
- No longer checks for resource-related values (container, env, hostname) in span attributes. This previous behavior did not follow the OTel spec."

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [37171]
4 changes: 4 additions & 0 deletions connector/datadogconnector/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package datadogconnector // import "github.com/open-telemetry/opentelemetry-coll
import (
"context"
"fmt"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/datadog"
IbraheemA marked this conversation as resolved.
Show resolved Hide resolved
"sync"
"time"

Expand Down Expand Up @@ -117,6 +118,9 @@ func getTraceAgentCfg(logger *zap.Logger, cfg TracesConfig, attributesTranslator
logger.Info("traces::compute_top_level_by_span_kind needs to be enabled in both the Datadog connector and Datadog exporter configs if both components are being used")
acfg.Features["enable_otlp_compute_top_level_by_span_kind"] = struct{}{}
}
if datadog.ReceiveResourceSpansV2FeatureGate.IsEnabled() {
acfg.Features["enable_receive_resource_spans_v2"] = struct{}{}
}
if v := cfg.BucketInterval; v > 0 {
acfg.BucketInterval = v
}
Expand Down
60 changes: 60 additions & 0 deletions connector/datadogconnector/connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,66 @@ func TestContainerTags(t *testing.T) {
assert.ElementsMatch(t, []string{"region:my-region", "zone:my-zone", "az:my-az"}, tags)
}

func TestReceiveResourceSpansV2(t *testing.T) {
t.Run("ReceiveResourceSpansV1", func(t *testing.T) {
testReceiveResourceSpansV2(t, false)
})
t.Run("ReceiveResourceSpansV2", func(t *testing.T) {
testReceiveResourceSpansV2(t, true)
})
}
func testReceiveResourceSpansV2(t *testing.T, enableReceiveResourceSpansV2 bool) {
if enableReceiveResourceSpansV2 {
if err := featuregate.GlobalRegistry().Set("datadog.EnableReceiveResourceSpansV2", true); err != nil {
t.Fatal(err)
}
}
connector, metricsSink := creteConnector(t)
err := connector.Start(context.Background(), componenttest.NewNopHost())
if err != nil {
t.Errorf("Error starting connector: %v", err)
return
}
defer func() {
_ = connector.Shutdown(context.Background())
}()

trace := generateTrace()
sattr := trace.ResourceSpans().At(0).ScopeSpans().At(0).Spans().At(0).Attributes()

sattr.PutStr("deployment.environment.name", "do-not-use")

err = connector.ConsumeTraces(context.Background(), trace)
assert.NoError(t, err)

for {
if len(metricsSink.AllMetrics()) > 0 {
break
}
time.Sleep(100 * time.Millisecond)
}

// check if the container tags are added to the metrics
metrics := metricsSink.AllMetrics()
assert.Len(t, metrics, 1)

ch := make(chan []byte, 100)
tr := newTranslatorWithStatsChannel(t, zap.NewNop(), ch)
_, err = tr.MapMetrics(context.Background(), metrics[0], nil)
require.NoError(t, err)
msg := <-ch
sp := &pb.StatsPayload{}

err = proto.Unmarshal(msg, sp)
require.NoError(t, err)

if enableReceiveResourceSpansV2 {
assert.Equal(t, "none", sp.Stats[0].Env)
} else {
assert.Equal(t, "do-not-use", sp.Stats[0].Env)
}
}

func newTranslatorWithStatsChannel(t *testing.T, logger *zap.Logger, ch chan []byte) *otlpmetrics.Translator {
options := []otlpmetrics.TranslatorOption{
otlpmetrics.WithHistogramMode(otlpmetrics.HistogramModeDistributions),
Expand Down
25 changes: 14 additions & 11 deletions connector/datadogconnector/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ go 1.22.0
require (
github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/metricsclient v0.60.1
github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/statsprocessor v0.60.1
github.com/DataDog/datadog-agent/pkg/proto v0.60.1
github.com/DataDog/datadog-agent/pkg/trace v0.60.1
github.com/DataDog/datadog-agent/pkg/proto v0.61.0-rc.1
IbraheemA marked this conversation as resolved.
Show resolved Hide resolved
github.com/DataDog/datadog-agent/pkg/trace v0.61.0-rc.1
github.com/DataDog/datadog-go/v5 v5.6.0
github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.22.0
github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/metrics v0.22.0
github.com/google/go-cmp v0.6.0
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datadogexporter v0.117.0
github.com/open-telemetry/opentelemetry-collector-contrib/internal/datadog v0.117.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/datadog v0.117.0
github.com/open-telemetry/opentelemetry-collector-contrib/processor/tailsamplingprocessor v0.117.0
github.com/patrickmn/go-cache v2.1.0+incompatible
Expand Down Expand Up @@ -55,8 +56,8 @@ require (
github.com/DataDog/datadog-agent/comp/otelcol/logsagentpipeline v0.60.1 // indirect
github.com/DataDog/datadog-agent/comp/otelcol/logsagentpipeline/logsagentpipelineimpl v0.60.1 // indirect
github.com/DataDog/datadog-agent/comp/otelcol/otlp/components/exporter/logsagentexporter v0.62.0-devel.0.20241213165407-f95df913d2b7 // indirect
github.com/DataDog/datadog-agent/comp/trace/compression/def v0.60.1 // indirect
github.com/DataDog/datadog-agent/comp/trace/compression/impl-gzip v0.60.1 // indirect
github.com/DataDog/datadog-agent/comp/trace/compression/def v0.61.0-rc.1 // indirect
github.com/DataDog/datadog-agent/comp/trace/compression/impl-gzip v0.61.0-rc.1 // indirect
github.com/DataDog/datadog-agent/pkg/collector/check/defaults v0.60.1 // indirect
github.com/DataDog/datadog-agent/pkg/config/env v0.60.1 // indirect
github.com/DataDog/datadog-agent/pkg/config/mock v0.60.1 // indirect
Expand All @@ -78,21 +79,21 @@ require (
github.com/DataDog/datadog-agent/pkg/logs/sources v0.60.1 // indirect
github.com/DataDog/datadog-agent/pkg/logs/status/statusinterface v0.60.1 // indirect
github.com/DataDog/datadog-agent/pkg/logs/status/utils v0.60.1 // indirect
github.com/DataDog/datadog-agent/pkg/obfuscate v0.60.1 // indirect
github.com/DataDog/datadog-agent/pkg/remoteconfig/state v0.60.1 // indirect
github.com/DataDog/datadog-agent/pkg/obfuscate v0.61.0-rc.1 // indirect
github.com/DataDog/datadog-agent/pkg/remoteconfig/state v0.61.0-rc.1 // indirect
github.com/DataDog/datadog-agent/pkg/status/health v0.60.1 // indirect
github.com/DataDog/datadog-agent/pkg/telemetry v0.60.1 // indirect
github.com/DataDog/datadog-agent/pkg/util/backoff v0.60.1 // indirect
github.com/DataDog/datadog-agent/pkg/util/cgroups v0.60.1 // indirect
github.com/DataDog/datadog-agent/pkg/util/cgroups v0.61.0-rc.1 // indirect
github.com/DataDog/datadog-agent/pkg/util/executable v0.60.1 // indirect
github.com/DataDog/datadog-agent/pkg/util/filesystem v0.60.1 // indirect
github.com/DataDog/datadog-agent/pkg/util/fxutil v0.60.1 // indirect
github.com/DataDog/datadog-agent/pkg/util/hostname/validate v0.60.1 // indirect
github.com/DataDog/datadog-agent/pkg/util/http v0.60.1 // indirect
github.com/DataDog/datadog-agent/pkg/util/log v0.60.1 // indirect
github.com/DataDog/datadog-agent/pkg/util/log v0.61.0-rc.1 // indirect
github.com/DataDog/datadog-agent/pkg/util/optional v0.60.1 // indirect
github.com/DataDog/datadog-agent/pkg/util/pointer v0.60.1 // indirect
github.com/DataDog/datadog-agent/pkg/util/scrubber v0.60.1 // indirect
github.com/DataDog/datadog-agent/pkg/util/pointer v0.61.0-rc.1 // indirect
github.com/DataDog/datadog-agent/pkg/util/scrubber v0.61.0-rc.1 // indirect
github.com/DataDog/datadog-agent/pkg/util/startstop v0.60.1 // indirect
github.com/DataDog/datadog-agent/pkg/util/statstracker v0.60.1 // indirect
github.com/DataDog/datadog-agent/pkg/util/system v0.60.1 // indirect
Expand Down Expand Up @@ -310,7 +311,7 @@ require (
golang.org/x/sys v0.29.0 // indirect
golang.org/x/term v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.7.0 // indirect
golang.org/x/time v0.8.0 // indirect
gonum.org/v1/gonum v0.15.1 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect
Expand Down Expand Up @@ -396,3 +397,5 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/pdata
replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/experimentalmetricmetadata => ../../pkg/experimentalmetricmetadata

replace github.com/open-telemetry/opentelemetry-collector-contrib/pkg/datadog => ../../pkg/datadog

replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/datadog => ../../internal/datadog
48 changes: 24 additions & 24 deletions connector/datadogconnector/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading