Repository navigation
[SVLS-10113] feat(otlp): forward OTLP metrics to Datadog's OTLP intake - #1533
jcaparelli15 wants to merge 3 commits into
Conversation
Accept POST /v1/metrics on the OTLP HTTP listener and forward the body unchanged to https://otlp.<DD_SITE>/v1/metrics through the proxy aggregator, with dd-otel-metric-config: {"resource_attributes_as_tags": true}. Enabled by DD_OTLP_CONFIG_METRICS_ENABLED or DD_METRICS_OTEL_ENABLED. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
🟢 Approval recommended
The OTLP metrics forwarding change has no active review issues.
No open issues 🎉
What changed in this PR
Adds OTLP metrics forwarding to the Lambda Extension so tracer-exported metrics, including feature flag evaluation counts, can reach Datadog’s OTLP intake.
Changes:
- Adds
POST /v1/metrics, queuing unchanged payloads through the proxy aggregator with resource attributes enabled as metric tags. - Enables metrics through either
DD_OTLP_CONFIG_METRICS_ENABLEDorDD_METRICS_OTEL_ENABLED, independently of traces, with a default HTTP port of 4318. - Adds unit tests for enablement, forwarding, response encoding, and disabled routes.
| File | Description |
|---|---|
bottlecap/src/otlp/mod.rs |
Separates trace and metric enablement checks and tests flag combinations. |
bottlecap/src/otlp/agent.rs |
Adds metrics routing, queueing, listener configuration, and handler tests. |
bottlecap/src/config/mod.rs |
Adds configuration support for DD_METRICS_OTEL_ENABLED. |
bottlecap/src/bin/bottlecap/main.rs |
Passes the shared proxy aggregator into the OTLP agent. |
Review effort: Balanced
|
…113-otlp-metrics-passthrough
- Rust: post a gzipped export to the OTLP agent, flush the queued request to a local intake, and check the body is unchanged and carries the API key and `dd-otel-metric-config`. - AWS: add a dd-trace-js function with `DD_METRICS_OTEL_ENABLED=true` to the otlp suite and assert its counter reaches Datadog with its full value and a `runtime-id` tag. It uses Node layer 144, since layer 132 bundles dd-trace 5.80, which has no OTel metrics. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| const DD_OTEL_METRIC_CONFIG_HEADER: &str = "dd-otel-metric-config"; | ||
| // Turns resource attributes (service, env, runtime-id, DD_TAGS) into metric tags. |
There was a problem hiding this comment.
Is runtime-id unconditionally included in the attributes? My concern is it could trigger high metric storage due to its unique cardinality.
| target_url: format!( | ||
| "https://otlp.{}{OTLP_METRICS_PATH}", | ||
| metrics_proxy.config.site | ||
| ), |
There was a problem hiding this comment.
Since it is hardcoded, nothing can redirect this URL, so otlp_metrics_forwarding_test.rs can't run the real binary. DD_SITE doesn't help: the URL is always https://otlp., so it can't point at the harness's http://127.0.0.1: intake which goes against our tests/HARNESS.md where No test reads internal state. DSM already does this with the same proxy aggregator, you may want to use that as reference.
litianningdatadog
left a comment
There was a problem hiding this comment.
left some comment
Problem
Tracer libraries with OpenTelemetry metrics turned on (for example dd-trace-js with
DD_METRICS_OTEL_ENABLED=true) export OTLP metrics tolocalhost:4318/v1/metrics. Feature flag evaluation counts (feature_flag.evaluations) are sent this way. In Lambda the Extension listens on that port but only handles/v1/traces, so these metrics are dropped.This PR
POST /v1/metricsto the OTLP HTTP listener. The body is forwarded unchanged tohttps://otlp.<DD_SITE>/v1/metricsthrough the proxy aggregator (store-and-forward), with the headerdd-otel-metric-config: {"resource_attributes_as_tags": true}. Nothing is translated.DD_OTLP_CONFIG_METRICS_ENABLEDorDD_METRICS_OTEL_ENABLEDis true. Metrics don't need a receiver endpoint to be configured, because the listener falls back to the tracers' default port.should_enable_otlp_agentintoshould_enable_otlp_tracesandshould_enable_otlp_metrics, so the listener can serve metrics with traces off, and the reverse.Testing
Test 1: unit tests
Steps
cargo nextest run --workspaceResult
New tests pass:
otlp::agent:test_v1_metrics_queues_request_for_otlp_intake,test_v1_metrics_replies_json_for_json_request,test_v1_metrics_not_found_when_metrics_disabled,test_v1_traces_not_found_when_only_metrics_enabledotlp:test_should_enable_otlp_metrics_from_otlp_config_without_endpoints,test_should_enable_otlp_metrics_from_tracer_flag,test_should_enable_otlp_metrics_with_traces_disabled,test_should_not_enable_otlp_metrics_by_defaultcargo fmt --checkandcargo clippy(default andtest-modefeatures) are clean.Test 2: forwarding through the flusher
Steps
cargo test --test otlp_metrics_forwarding_testResult
metrics_export_is_forwarded_unchanged_with_metric_config_headerposts a gzipped export to the OTLP agent on a free port, flushes the queued request to the local fault intake, and checks it arrives byte for byte withDD-API-KEY,dd-otel-metric-config,Content-TypeandContent-Encoding. The agent always targetshttps://otlp.<site>, so the test points the queued request at the local intake before the flush.Test 3: AWS integration (
otlpsuite)Steps
otel-metrics-node-lambda, runs dd-trace-js withDD_METRICS_OTEL_ENABLED=trueand adds 5 to an OTel counter.otlp.test.tsqueries Datadog for the counter byservice.Result
Passes. The tests assert the count is exactly 5, both overall and filtered on
runtime-id:*. The function uses Node layer 144 (dd-trace 6.24), because the suite's default layer, 132, bundles dd-trace 5.80, which has no OTel metrics.🤖 Generated with Claude Code