Add native OTLP export marker to trace chunks - #4240
Merged
Merged
Conversation
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>
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: a8f2290 | Docs | View more details | Give us feedback! |
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The shared serialization path correctly applies the marker once per chunk and the behavior has focused coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Adds the native OTLP export marker to the first serialized span of every trace chunk.
Changes:
- Emits
_dd.sdk.otlp_export: "false"during native serialization. - Adds focused multi-chunk coverage.
- Updates test helpers and affected expectations.
| File | Description |
|---|---|
tracer/serializer.c |
Adds the marker to each chunk’s first span. |
tests/ext/sdk_otlp_export_marker.phpt |
Verifies marker placement across two chunks. |
tests/ext/sandbox/safe_to_string_metadata.phpt |
Excludes the new generated marker. |
tests/ext/sandbox/dd_dumper.inc |
Filters the marker from generic dumps. |
tests/ext/root_span_url_with_post_no_param.phpt |
Updates expected metadata. |
tests/ext/root_span_url_with_post_no_param_set.phpt |
Updates expected metadata. |
tests/ext/root_span_url_as_resource_names.phpt |
Updates expected metadata. |
tests/ext/root_span_url_as_resource_names_no_host.phpt |
Updates expected metadata. |
tests/ext/referrer_extraction_05.phpt |
Updates expected metadata. |
tests/ext/referrer_extraction_04.phpt |
Updates expected metadata. |
tests/ext/referrer_extraction_03.phpt |
Updates expected metadata. |
tests/ext/referrer_extraction_02.phpt |
Updates expected metadata. |
tests/ext/referrer_extraction_01.phpt |
Updates expected metadata. |
tests/ext/extract_server_values.phpt |
Updates expected metadata. |
tests/ext/distributed_tracing/distributed_trace_overwrite_active_span.phpt |
Filters the generated marker. |
tests/Common/SpanChecker.php |
Ignores the marker unless explicitly asserted. |
tests/Common/SnapshotTestTrait.php |
Excludes the marker from snapshots. |
appsec/tests/extension/root_span_add_tag.phpt |
Updates expected metadata. |
appsec/tests/extension/root_span_add_tag_with_intermediate_spans.phpt |
Updates expected metadata. |
appsec/tests/extension/rinit_root_span_add_tag.phpt |
Updates expected metadata. |
appsec/tests/extension/rinit_record_span_tags.phpt |
Updates expected metadata. |
appsec/tests/extension/rinit_record_span_tags_fail.phpt |
Updates expected metadata. |
appsec/tests/extension/ddtrace_basic.phpt |
Updates expected metadata. |
appsec/tests/extension/client_init_record_span_tags.phpt |
Updates expected metadata. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
mhlidd
marked this pull request as ready for review
September 29, 2026 18:48
This was referenced Sep 29, 2026
Contributor
Author
|
@bwoebi Yup that's what we've done for repos that support V1! Additionally, if OTLP is ever supported in PHP, we would also add it as a Resource Attribute there. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 theis_first_spanblock inddtrace_serialize_span_to_rust_span(tracer/serializer.c), right before_dd.tags.process, using the existingddog_add_str_span_meta_strFFI 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.nameandspan_source. That's unreliable: the OpenTelemetry Collector'sdatadogreceiverhardcodestelemetry.sdk.name:Datadogon 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_enabledis hardcoded false), so the value is always"false". The OTLP-onlydatadog.sdk.semanticsresource attribute doesn't apply.Details:
dd_trace_serialize_closed_spansall serialize through this function. No other path writes chunk-level tags.is_first_spanis true when the trace is still empty, so if stats computation drops a span, the next serialized span gets the marker.Tests:
tests/ext/sdk_otlp_export_marker.phptbuilds two traces of three spans and checks the marker is'false'on each chunk's first span only.SpanChecker,SnapshotTestTrait(test-agent ignore list) anddd_dumper.incignore 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..phptfiles undertests/ext/and 7 underappsec/tests/extension/that print first-span meta.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:
_dd.sdk.otlp_exportfrom Tracer to Intake datadog-agent#56749 hoists the marker from the first span of the first chunk into the payload.This change was written with AI assistance and reviewed before submission.
Reviewer checklist
🤖 Generated with Claude Code