Skip to content

[SVLS-10113] feat(otlp): forward OTLP metrics to Datadog's OTLP intake - #1533

Open
jcaparelli15 wants to merge 3 commits into
mainfrom
joe.caparelli/SVLS-10113-otlp-metrics-passthrough
Open

jcaparelli15 wants to merge 3 commits into
mainfrom
joe.caparelli/SVLS-10113-otlp-metrics-passthrough

Conversation

@jcaparelli15

@jcaparelli15 jcaparelli15 commented Nov 19, 2026 •

Copy link
Copy Markdown

Problem

Tracer libraries with OpenTelemetry metrics turned on (for example dd-trace-js with DD_METRICS_OTEL_ENABLED=true) export OTLP metrics to localhost: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

  • Adds POST /v1/metrics to the OTLP HTTP listener. The body is forwarded unchanged to https://otlp.<DD_SITE>/v1/metrics through the proxy aggregator (store-and-forward), with the header dd-otel-metric-config: {"resource_attributes_as_tags": true}. Nothing is translated.
  • Turns the route on when DD_OTLP_CONFIG_METRICS_ENABLED or DD_METRICS_OTEL_ENABLED is true. Metrics don't need a receiver endpoint to be configured, because the listener falls back to the tracers' default port.
  • Splits should_enable_otlp_agent into should_enable_otlp_traces and should_enable_otlp_metrics, so the listener can serve metrics with traces off, and the reverse.

Testing

Test 1: unit tests

Steps

  1. cargo nextest run --workspace

Result

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_enabled
  • otlp: 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_default

cargo fmt --check and cargo clippy (default and test-mode features) are clean.

Test 2: forwarding through the flusher

Steps

  1. cargo test --test otlp_metrics_forwarding_test

Result

metrics_export_is_forwarded_unchanged_with_metric_config_header posts 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 with DD-API-KEY, dd-otel-metric-config, Content-Type and Content-Encoding. The agent always targets https://otlp.<site>, so the test points the queued request at the local intake before the flush.

Test 3: AWS integration (otlp suite)

Steps

  1. A new function, otel-metrics-node-lambda, runs dd-trace-js with DD_METRICS_OTEL_ENABLED=true and adds 5 to an OTel counter.
  2. otlp.test.ts queries Datadog for the counter by service.

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

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>
@jcaparelli15
jcaparelli15 requested a review from a team as a code owner November 19, 2026 20:48
@jcaparelli15
jcaparelli15 requested review from lym953 and a balanced review from Copilot November 19, 2026 20:48
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T16:11:38.785275Z 36b3d0d New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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_ENABLED or DD_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

@datadog-official

datadog-official Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Pipelines

✨ Unblock PR with BitsAI

⚠️ Warnings

Your PR has warnings. Please review the issues below.

🚦 1 Pipeline job failed

Bottlecap (Rust) | Audit — 🔧 Needs a code fix, caused by this PR

View more details · View in GitHub Actions

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 36b3d0d | Docs | View more details | Give us feedback!

jcaparelli15 and others added 2 commits November 20, 2026 10:55
- 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>
Comment on lines +47 to +48
const DD_OTEL_METRIC_CONFIG_HEADER: &str = "dd-otel-metric-config";
// Turns resource attributes (service, env, runtime-id, DD_TAGS) into metric tags.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 litianningdatadog left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants