Skip to content

Add support for the v3 metrics intake payload#7144

Open
ajgajg1134 wants to merge 4 commits into
mainfrom
andrew.glaude/metricsFix
Open

Add support for the v3 metrics intake payload#7144
ajgajg1134 wants to merge 4 commits into
mainfrom
andrew.glaude/metricsFix

Conversation

@ajgajg1134

@ajgajg1134 ajgajg1134 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

What

Adds end-to-end proxy support for the agent's /api/intake/metrics/v3/series intake, which uses a columnar, dictionary-encoded protobuf format (very different from the v2 MetricPayload) and streams its body as several concatenated zstd frames. This was changed here: DataDog/datadog-agent#52059

The diff numbers look scary, but most of that is just a sample expected output file I used to validate the decoder via the TEST_THE_TESTS scenario

Changes

  • utils/proxy/core.pyget_decoded_content() decodes multi-frame zstd bodies with a frame-aware reader. mitmproxy's message.content only decodes the first zstd frame, silently truncating the v3 payload.
  • utils/proxy/_decoders/metrics_v3.proto / .descriptor — a cherry-picked proto (Payload/Metadata/MetricData) from the agent's dogstatsdhttp/payload.proto, built through the canonical update_protobuf.sh pipeline (protoc 3.21.12), like the other descriptors. metricData is declared repeated (wire-compatible with the upstream singular field) so multiple MetricData messages per request yield a list instead of protobuf merging them.
  • utils/proxy/_decoders/metrics_v3.py — protobuf parses the envelope and the packed scalar columns; the decoder undoes only what protobuf can't express — the string-dictionary unpacking, the delta-encoding of reference columns, and the self-framed tagset reconstruction — producing a v2-like {"series": [...]} dict so get_metrics keeps working unchanged.
  • utils/proxy/_decoders/protobuf_schemas.py — exposes MetricsV3Payload.
  • utils/proxy/_deserializer.py — routes the v3 path to the decoder.
  • utils/interfaces/_agent.pyget_metrics() now also reads the v3 series path.

Tests

tests/test_the_test/test_metrics_v3_decoder.py (runs under TEST_THE_TEST, no infra):

  • 3 synthetic tests exercising every decoder branch (string dicts, tagset inheritance via negative refs, delta-encoded ref columns, plain-uvarint columns, missing optional columns, tagsRef=0, multiple MetricData blobs).
  • 1 golden snapshot of a real 286-series payload captured from RUNTIME_METRICS_ENABLED.

These were written before the proto-based decoder rewrite and pass identically before and after, so they double as a refactor guard.

Verified: guard tests green, ./format.sh green.

🤖 Generated with Claude Code but also reviewed and edited by Andrew

The agent's /api/intake/metrics/v3/series intake uses a columnar,
dictionary-encoded protobuf format that is very different from the v2
MetricPayload, and streams its body as several concatenated zstd frames.
This adds end-to-end support for it in the proxy:

- core.py: decode multi-frame zstd bodies (mitmproxy's content only
  decodes the first frame, silently truncating the payload).
- _decoders/metrics_v3.{proto,descriptor,py}: a cherry-picked proto (built
  via update_protobuf.sh) parses the envelope and packed columns; the
  decoder undoes the dictionary indirection, delta-encoding and tagset
  framing layered on top, producing a v2-like {"series": [...]} dict.
- _deserializer.py: route the v3 path to the decoder.
- _agent.py: get_metrics() now also reads the v3 series path.

Adds characterization tests (synthetic branch coverage plus a real
286-series payload snapshot captured from RUNTIME_METRICS_ENABLED) under
the TEST_THE_TEST scenario.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

CODEOWNERS have been resolved as:

tests/test_the_test/metrics_v3_fixtures/sample.b64                      @DataDog/system-tests-core
tests/test_the_test/metrics_v3_fixtures/sample_expected.json            @DataDog/system-tests-core
tests/test_the_test/test_metrics_v3_decoder.py                          @DataDog/system-tests-core
utils/proxy/_decoders/metrics_v3.descriptor                             @DataDog/system-tests-core
utils/proxy/_decoders/metrics_v3.proto                                  @DataDog/system-tests-core
utils/proxy/_decoders/metrics_v3.py                                     @DataDog/system-tests-core
utils/interfaces/_agent.py                                              @DataDog/system-tests-core
utils/proxy/_decoders/protobuf_schemas.py                               @DataDog/system-tests-core
utils/proxy/_deserializer.py                                            @DataDog/system-tests-core
utils/proxy/core.py                                                     @DataDog/system-tests-core
utils/scripts/update_protobuf.sh                                        @DataDog/system-tests-core

@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Jun 16, 2026

Copy link
Copy Markdown

Pipelines  Tests

Fix all issues with BitsAI

⚠️ Warnings

🚦 13 Pipeline jobs failed

Testing the test | System Tests (nodejs, dev) / End-to-end #1 / express4 1   View in Datadog   GitHub Actions

Testing the test | System Tests (nodejs, dev) / End-to-end #1 / express4-typescript 1   View in Datadog   GitHub Actions

Testing the test | System Tests (nodejs, dev) / End-to-end #1 / express5 1   View in Datadog   GitHub Actions

View all 13 failed jobs.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: a647505 | Docs | Datadog PR Page | Give us feedback!

@ajgajg1134 ajgajg1134 marked this pull request as ready for review June 16, 2026 14:18
@ajgajg1134 ajgajg1134 requested a review from a team as a code owner June 16, 2026 14:18

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f132cec6ef

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread utils/proxy/core.py
Comment thread utils/proxy/_decoders/metrics_v3.py
get_metrics() now reads the v3 path, but the decoder dropped the per-point
columns, so callers that sum points (e.g. tests/ffe/test_flag_eval_metrics.py
::test_ffe_eval_metric_count) saw 0 for v3 payloads.

Decode the per-point columns into a v2-shaped `points` field: timestamps is a
single delta-encoded stream consumed sequentially across series, and each
value is read from the vals* column selected by the series' value type
(type & 0x30 -> sint64 / float32 / float64 / zero), with an independent cursor
per column. Emitted as [{"value": <float>, "timestamp": <str>}], matching the
v2 MessageToDict(MetricPayload) shape, and only when non-empty.

Adds a synthetic test covering all four value types and re-freezes the real
286-series snapshot (now with points).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ajgajg1134 ajgajg1134 enabled auto-merge (squash) June 18, 2026 14:25
@datadog-system-tests-org

datadog-system-tests-org Bot commented Jun 18, 2026

Copy link
Copy Markdown

Pipelines

⚠️ Warnings

🚦 12 Pipeline jobs failed

Testing the test | System Tests (nodejs, dev) / End-to-end #1 / express4 1   View in Datadog   GitHub Actions

Testing the test | System Tests (nodejs, dev) / End-to-end #1 / express4-typescript 1   View in Datadog   GitHub Actions

Testing the test | System Tests (nodejs, dev) / End-to-end #1 / express5 1   View in Datadog   GitHub Actions

View all 12 failed jobs.

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: a647505 | Docs | Give us feedback!

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.

2 participants