Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into feat/export-telemet…
Browse files Browse the repository at this point in the history
…rygen-funcs-for-tests
  • Loading branch information
Erog38 committed Jan 15, 2025
2 parents 5112ea8 + 0788185 commit 9c590e0
Show file tree
Hide file tree
Showing 15 changed files with 252 additions and 25 deletions.
14 changes: 14 additions & 0 deletions .chloggen/add-feature-flag-for-updated-datadog-span-receiver.yaml
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]
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ confmap/provider/s3provider/ @open-telemetry/collector-cont
confmap/provider/secretsmanagerprovider/ @open-telemetry/collector-contrib-approvers @driverpt @atoulme

connector/countconnector/ @open-telemetry/collector-contrib-approvers @djaglowski @jpkrohling
connector/datadogconnector/ @open-telemetry/collector-contrib-approvers @mx-psi @dineshg13 @ankitpatel96 @jade-guiton-dd
connector/datadogconnector/ @open-telemetry/collector-contrib-approvers @mx-psi @dineshg13 @ankitpatel96 @jade-guiton-dd @IbraheemA
connector/exceptionsconnector/ @open-telemetry/collector-contrib-approvers @marctc
connector/failoverconnector/ @open-telemetry/collector-contrib-approvers @akats7 @fatsheep9146
connector/grafanacloudconnector/ @open-telemetry/collector-contrib-approvers @rlankfo @jcreixell
Expand Down Expand Up @@ -54,7 +54,7 @@ exporter/carbonexporter/ @open-telemetry/collector-cont
exporter/cassandraexporter/ @open-telemetry/collector-contrib-approvers @atoulme @emreyalvac
exporter/clickhouseexporter/ @open-telemetry/collector-contrib-approvers @hanjm @dmitryax @Frapschen @SpencerTorres
exporter/coralogixexporter/ @open-telemetry/collector-contrib-approvers @povilasv
exporter/datadogexporter/ @open-telemetry/collector-contrib-approvers @mx-psi @dineshg13 @liustanley @songy23 @mackjmr @ankitpatel96 @jade-guiton-dd
exporter/datadogexporter/ @open-telemetry/collector-contrib-approvers @mx-psi @dineshg13 @liustanley @songy23 @mackjmr @ankitpatel96 @jade-guiton-dd @IbraheemA
exporter/datasetexporter/ @open-telemetry/collector-contrib-approvers @atoulme @martin-majlis-s1 @zdaratom-s1 @tomaz-s1
exporter/dorisexporter/ @open-telemetry/collector-contrib-approvers @atoulme @joker-star-l
exporter/elasticsearchexporter/ @open-telemetry/collector-contrib-approvers @JaredTan95 @carsonip @lahsivjar
Expand Down Expand Up @@ -146,7 +146,7 @@ internal/tools/ @open-telemetry/collector-cont

pkg/batchperresourceattr/ @open-telemetry/collector-contrib-approvers @atoulme @dmitryax
pkg/batchpersignal/ @open-telemetry/collector-contrib-approvers @jpkrohling
pkg/datadog/ @open-telemetry/collector-contrib-approvers @mx-psi @dineshg13 @liustanley @songy23 @mackjmr @ankitpatel96 @jade-guiton-dd
pkg/datadog/ @open-telemetry/collector-contrib-approvers @mx-psi @dineshg13 @liustanley @songy23 @mackjmr @ankitpatel96 @jade-guiton-dd @IbraheemA
pkg/experimentalmetricmetadata/ @open-telemetry/collector-contrib-approvers @dmitryax
pkg/golden/ @open-telemetry/collector-contrib-approvers @djaglowski @atoulme
pkg/kafka/topic/ @open-telemetry/collector-contrib-approvers @pavolloffay @MovieStoreGuy
Expand Down
2 changes: 1 addition & 1 deletion connector/datadogconnector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
| ------------- |-----------|
| Distributions | [contrib] |
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Aconnector%2Fdatadog%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aconnector%2Fdatadog) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Aconnector%2Fdatadog%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aconnector%2Fdatadog) |
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@mx-psi](https://www.github.com/mx-psi), [@dineshg13](https://www.github.com/dineshg13), [@ankitpatel96](https://www.github.com/ankitpatel96), [@jade-guiton-dd](https://www.github.com/jade-guiton-dd) |
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@mx-psi](https://www.github.com/mx-psi), [@dineshg13](https://www.github.com/dineshg13), [@ankitpatel96](https://www.github.com/ankitpatel96), [@jade-guiton-dd](https://www.github.com/jade-guiton-dd), [@IbraheemA](https://www.github.com/IbraheemA) |
| Emeritus | [@gbbr](https://www.github.com/gbbr) |

[beta]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#beta
Expand Down
5 changes: 5 additions & 0 deletions connector/datadogconnector/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
semconv "go.opentelemetry.io/collector/semconv/v1.27.0"
"go.opentelemetry.io/otel/metric/noop"
"go.uber.org/zap"

"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/datadog"
)

// traceToMetricConnector is the schema for connector
Expand Down Expand Up @@ -117,6 +119,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
61 changes: 61 additions & 0 deletions connector/datadogconnector/connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,67 @@ 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
4 changes: 2 additions & 2 deletions connector/datadogconnector/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ status:
beta: [traces_to_metrics, traces_to_traces]
distributions: [contrib]
codeowners:
active: [mx-psi, dineshg13, ankitpatel96, jade-guiton-dd]
active: [mx-psi, dineshg13, ankitpatel96, jade-guiton-dd, IbraheemA]
emeritus: [gbbr]

tests:
goleak:
skip: true
skip: true
2 changes: 1 addition & 1 deletion exporter/datadogexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
| Stability | [beta]: traces, metrics, logs |
| Distributions | [contrib] |
| Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aopen%20label%3Aexporter%2Fdatadog%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aexporter%2Fdatadog) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector-contrib?query=is%3Aissue%20is%3Aclosed%20label%3Aexporter%2Fdatadog%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aexporter%2Fdatadog) |
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@mx-psi](https://www.github.com/mx-psi), [@dineshg13](https://www.github.com/dineshg13), [@liustanley](https://www.github.com/liustanley), [@songy23](https://www.github.com/songy23), [@mackjmr](https://www.github.com/mackjmr), [@ankitpatel96](https://www.github.com/ankitpatel96), [@jade-guiton-dd](https://www.github.com/jade-guiton-dd) |
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@mx-psi](https://www.github.com/mx-psi), [@dineshg13](https://www.github.com/dineshg13), [@liustanley](https://www.github.com/liustanley), [@songy23](https://www.github.com/songy23), [@mackjmr](https://www.github.com/mackjmr), [@ankitpatel96](https://www.github.com/ankitpatel96), [@jade-guiton-dd](https://www.github.com/jade-guiton-dd), [@IbraheemA](https://www.github.com/IbraheemA) |
| Emeritus | [@gbbr](https://www.github.com/gbbr) |

[beta]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#beta
Expand Down
4 changes: 2 additions & 2 deletions exporter/datadogexporter/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ status:
beta: [traces, metrics, logs]
distributions: [contrib]
codeowners:
active: [mx-psi, dineshg13, liustanley, songy23, mackjmr, ankitpatel96, jade-guiton-dd]
active: [mx-psi, dineshg13, liustanley, songy23, mackjmr, ankitpatel96, jade-guiton-dd, IbraheemA]
emeritus: [gbbr]

tests:
Expand All @@ -22,4 +22,4 @@ tests:
expect_consumer_error: true
goleak:
setup: "setupTestMain(m)"
skip: true
skip: true
4 changes: 4 additions & 0 deletions exporter/datadogexporter/traces_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datadogexporter/internal/hostmetadata"
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datadogexporter/internal/metrics"
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/datadogexporter/internal/scrub"
"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/datadog"
)

var traceCustomHTTPFeatureGate = featuregate.GlobalRegistry().MustRegister(
Expand Down Expand Up @@ -238,6 +239,9 @@ func newTraceAgentConfig(ctx context.Context, params exporter.Settings, cfg *Con
if cfg.Traces.ComputeTopLevelBySpanKind {
acfg.Features["enable_otlp_compute_top_level_by_span_kind"] = struct{}{}
}
if datadog.ReceiveResourceSpansV2FeatureGate.IsEnabled() {
acfg.Features["enable_receive_resource_spans_v2"] = struct{}{}
}
tracelog.SetLogger(&zaplogger{params.Logger}) // TODO: This shouldn't be a singleton
return acfg, nil
}
Loading

0 comments on commit 9c590e0

Please sign in to comment.