Skip to content

feat(stats): emit canonical gRPC status name for OTLP rpc.response.status_code#2183

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits into
mainfrom
ida613/otlp-rpc-status-name
Jul 1, 2026
Merged

feat(stats): emit canonical gRPC status name for OTLP rpc.response.status_code#2183
gh-worker-dd-mergequeue-cf854d[bot] merged 4 commits into
mainfrom
ida613/otlp-rpc-status-name

Conversation

@mabdinur

Copy link
Copy Markdown
Contributor

Summary

The OTLP trace-metrics path emits the numeric gRPC status code as a string (e.g. "0", "14") for the rpc.response.status_code data-point attribute. The OTel gRPC semantic conventions require the canonical status NAME (e.g. OK, NOT_FOUND, UNAVAILABLE).

This PR maps the numeric code back to the canonical name at OTLP emission only:

  • Adds grpc_status_code_to_name in libdd-trace-stats (span_concentrator), the inverse of the existing grpc_status_str_to_int_value name->code normalization, with the canonical list kept next to the forward table as a single source of truth.
  • libdd-data-pipeline OTLP build_attributes now emits the name (omitting the attribute for empty/unmapped codes).

Why map instead of pass through the raw string?

By the time stats reach the OTLP/agent boundary, grpc.status.code has already been normalized to a numeric u8 in the aggregation key, so the raw name is gone. Mapping the numeric code back to the name reuses that existing normalization and yields the canonical name for every input form ("OK", "ok", "StatusCode.OK", "0", and numeric metrics) without changing the aggregation data model.

Unchanged

  • /v0.6/stats agent payload (encode_grouped_stats still emits the numeric code).
  • The aggregation key (grpc_status_code: Option<u8>) and grouping/cardinality behavior.
  • The SHM (datadog-ipc) path.

Test plan

  • cargo test -p libdd-trace-stats (incl. test_grpc_status_code_to_name)
  • cargo test -p libdd-data-pipeline --lib otlp::metrics (incl. emits_canonical_grpc_status_name_for_rpc_response_status_code)
  • system-tests Test_FR06...::test_fr06_7_rpc_status_code for python once this ships and the python OTLP suite is enabled

Notes

Draft: depends on coordinating the system-tests fr06_7 enablement for python (currently skipped via file-level missing_feature) and a libdatadog bump in dd-trace-py.

Made with Cursor

…atus_code

The OTLP trace-metrics path emitted the numeric gRPC status code as a string for
rpc.response.status_code, but the OTel gRPC semantic conventions require the
canonical status NAME (e.g. OK, NOT_FOUND, UNAVAILABLE).

Add grpc_status_code_to_name in libdd-trace-stats (the inverse of the existing
name->code normalization) and use it at OTLP emission. The /v0.6/stats agent
payload, the aggregation key, and the SHM path are unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
@datadog-official

datadog-official Bot commented Jun 30, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 74.34% (+0.03%)

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

@github-actions

Copy link
Copy Markdown
Contributor

Clippy Allow Annotation Report

Comparing clippy allow annotations between branches:

  • Base Branch: origin/main
  • PR Branch: origin/ida613/otlp-rpc-status-name

Summary by Rule

Rule Base Branch PR Branch Change
unwrap_used 1 1 No change (0%)
Total 1 1 No change (0%)

Annotation Counts by File

File Base Branch PR Branch Change
libdd-data-pipeline/src/otlp/metrics.rs 1 1 No change (0%)

Annotation Stats by Crate

Crate Base Branch PR Branch Change
clippy-annotation-reporter 5 5 No change (0%)
datadog-ffe-ffi 1 1 No change (0%)
datadog-ipc 22 22 No change (0%)
datadog-live-debugger 4 4 No change (0%)
datadog-live-debugger-ffi 10 10 No change (0%)
datadog-profiling-replayer 4 4 No change (0%)
datadog-sidecar 45 45 No change (0%)
libdd-common 13 13 No change (0%)
libdd-common-ffi 12 12 No change (0%)
libdd-data-pipeline 6 6 No change (0%)
libdd-ddsketch 2 2 No change (0%)
libdd-dogstatsd-client 1 1 No change (0%)
libdd-profiling 13 13 No change (0%)
libdd-remote-config 3 3 No change (0%)
libdd-telemetry 20 20 No change (0%)
libdd-tinybytes 4 4 No change (0%)
libdd-trace-normalization 2 2 No change (0%)
libdd-trace-obfuscation 3 3 No change (0%)
libdd-trace-stats 1 1 No change (0%)
libdd-trace-utils 11 11 No change (0%)
Total 182 182 No change (0%)

About This Report

This report tracks Clippy allow annotations for specific rules, showing how they've changed in this PR. Decreasing the number of these annotations generally improves code quality.

@dd-octo-sts

dd-octo-sts Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Artifact Size Benchmark Report

aarch64-alpine-linux-musl
Artifact Baseline Commit Change
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 85.65 MB 85.66 MB +0% (+3.96 KB) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 7.88 MB 7.88 MB 0% (0 B) 👌
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 96.82 MB 96.82 MB +0% (+3.58 KB) 👌
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.60 MB 10.60 MB +0% (+336 B) 👌
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 25.41 MB 25.41 MB +0% (+512 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 88.04 KB 88.04 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 184.50 MB 184.51 MB +0% (+8.00 KB) 👌
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 945.48 MB 945.49 MB +0% (+6.48 KB) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 8.29 MB 8.29 MB +0% (+512 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 88.04 KB 88.04 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 24.51 MB 24.51 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 48.85 MB 48.85 MB +0% (+1.53 KB) 👌
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 22.02 MB 22.02 MB +0% (+1.00 KB) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 89.42 KB 89.42 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 188.51 MB 188.51 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 932.67 MB 932.68 MB +0% (+6.26 KB) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 6.41 MB 6.41 MB +0% (+512 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 89.42 KB 89.42 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 26.32 MB 26.32 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 46.48 MB 46.48 MB +0% (+1.26 KB) 👌
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 76.39 MB 76.39 MB +0% (+2.83 KB) 👌
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 8.76 MB 8.76 MB 0% (0 B) 👌
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 91.87 MB 91.87 MB +0% (+2.41 KB) 👌
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.66 MB 10.66 MB 0% (0 B) 👌

@mabdinur

Copy link
Copy Markdown
Contributor Author

End-to-end validation (dd-trace-py + system-tests)

Validated this change end-to-end through the Python tracer and the system-tests OTLP trace-metrics parametric suite.

Result: all green

  • test_fr06_7_rpc_status_code[OK | NOT_FOUND | UNAVAILABLE] -> 3 passed
  • Full tests/parametric/test_otlp_trace_metrics.py -> 47 passed

The round-trip works as designed: dd-trace-py sets grpc.status.code="OK" -> libdatadog normalizes name->numeric (0) in aggregation -> the new grpc_status_code_to_name reverse lookup emits the canonical "OK" for rpc.response.status_code at OTLP emission (/v0.6/stats payload and aggregation key unchanged).

Note on how it was built

dd-trace-py (munir/otlp-trace-metrics-export) currently pins libdatadog at the v37.0.0 tag. This branch sits ~5 commits past v37.0.0 (including breaking feat(stats)! changes), and pointing dd-trace-py's native ext directly at it caused transitive dependency drift (a broken hyper 1.9.0) unrelated to this change.

To isolate only this commit for validation, it was cherry-picked onto v37.0.0 (range-diff confirms an identical diff to 8ec3bb982) and dd-trace-py built cleanly against that. No change to the code in this PR is needed -- once this lands on a libdatadog release that dd-trace-py adopts, the behavior validated here applies as-is.

Co-authored-by: Cursor <cursoragent@cursor.com>
@mabdinur mabdinur marked this pull request as ready for review June 30, 2026 21:01
@mabdinur mabdinur requested review from a team as code owners June 30, 2026 21:01
@mabdinur mabdinur requested review from vpellan and removed request for a team June 30, 2026 21:01
Comment thread libdd-trace-stats/src/span_concentrator/aggregation.rs Outdated
mabdinur and others added 2 commits July 1, 2026 10:38
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…_name

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants