Skip to content

Add native OTLP export marker to trace chunks - #4240

Draft
mhlidd wants to merge 1 commit into
masterfrom
matthew.li/otlp-adoption-markers
Draft

mhlidd wants to merge 1 commit into
masterfrom
matthew.li/otlp-adoption-markers

Conversation

@mhlidd

@mhlidd mhlidd commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Description

This adds _dd.sdk.otlp_export: "false" to the meta of the first span of each trace chunk. It's set at the start of the is_first_span block in ddtrace_serialize_span_to_rust_span (tracer/serializer.c), right before _dd.tags.process, using the existing ddog_add_str_span_meta_str FFI call. No libdatadog change is needed.

This is part of the "Measuring Adoption of Datadog SDKs in OTel Mode (Traces)" RFC. Today the backend infers which spans came from Datadog SDKs exporting OTLP at ingest time, using telemetry.sdk.name and span_source. That's unreliable: the OpenTelemetry Collector's datadogreceiver hardcodes telemetry.sdk.name:Datadog on native payloads it converts. So tracers now declare their export mode on the wire. "true" goes on the OTLP resource when exporting over OTLP, and "false" goes on the first span of each chunk for native export. An absent marker means an older tracer.

PHP has no OTLP trace export (otlp_traces_export_enabled is hardcoded false), so the value is always "false". The OTLP-only datadog.sdk.semantics resource attribute doesn't apply.

Details:

  • Send paths: the sidecar sender, the in-process curl sender and dd_trace_serialize_closed_spans all serialize through this function. No other path writes chunk-level tags.
  • Unconditional: the marker isn't gated like process tags, and doesn't guard against a user tag with the same key. That matches the other tracers.
  • Dropped spans: is_first_span is true when the trace is still empty, so if stats computation drops a span, the next serialized span gets the marker.

Tests:

  • New: tests/ext/sdk_otlp_export_marker.phpt builds two traces of three spans and checks the marker is 'false' on each chunk's first span only.
  • Helpers: SpanChecker, SnapshotTestTrait (test-agent ignore list) and dd_dumper.inc ignore the marker the same way they already ignore _dd.tags.process / _dd.svc_src. So existing tag and snapshot assertions don't need to list it.
  • Updated expectations: 13 .phpt files under tests/ext/ and 7 under appsec/tests/extension/ that print first-span meta.
  • Not run locally: the Docker build environment ran out of disk, so nothing was built or run. CI is the first run. The FFI call matches the existing ddog_add_str_span_meta_str(rust_span, "track_error", "false") usage in the same file. Affected tests were found by grepping, so CI may surface a missed expectation.

Related changes:

This change was written with AI assistance and reviewed before submission.

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

🤖 Generated with Claude Code

Tag the first span of each chunk with _dd.sdk.otlp_export=false, next to
_dd.tags.process, so the backend can tell native-exported spans from spans
that reached it through the datadogreceiver instead of inferring it at
ingest time. PHP has no OTLP trace export, so the value is always false.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@mhlidd mhlidd added the AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos label Sep 25, 2026
@datadog-official

datadog-official Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Pipelines  Tests

✨ Unblock PR with BitsAI

❌ Errors

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 10 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-php | test_web_drupal_101: [8.2, cgi-fcgi] — ❄️ 2 known flaky tests

View more details · View in GitLab

↳ ❄️ Known flaky: testScenarioGetToMissingRoute from tests/Integrations/Drupal/V10_1.DDTrace\Tests\Integrations\Drupal\V10_1\CommonScenariosTest

↳ ❄️ Known flaky: testScenarioGetWithView from tests/Integrations/Drupal/V10_1.DDTrace\Tests\Integrations\Drupal\V10_1\CommonScenariosTest

DataDog/apm-reliability/dd-trace-php | test_extension_ci: [7.4] — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

DataDog/apm-reliability/dd-trace-php | test_extension_ci: [8.4] — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

View all 10 failed jobs.

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 68.26% (+0.00%)

Useful? React with 👍 / 👎

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

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

Labels

AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant