Add OTLP trace export via the sidecar (OTEL_TRACES_EXPORTER=otlp)#3971
Draft
bm1549 wants to merge 4 commits into
Draft
Add OTLP trace export via the sidecar (OTEL_TRACES_EXPORTER=otlp)#3971bm1549 wants to merge 4 commits into
bm1549 wants to merge 4 commits into
Conversation
Add config plumbing for OTLP trace export, triggered by OTEL_TRACES_EXPORTER=otlp, mirroring the existing OTLP metrics endpoint path. Configuration: - OTEL_TRACES_EXPORTER=otlp now enables OTLP trace export via a new DD_TRACE_OTLP_ENABLED config (previously only "none" was handled). - OTEL_EXPORTER_OTLP_TRACES_ENDPOINT used as-is; falls back to OTEL_EXPORTER_OTLP_ENDPOINT (trailing slash stripped, /v1/traces appended); computed default http://<agent_host>:4318/v1/traces. - OTEL_EXPORTER_OTLP_TRACES_HEADERS / _TIMEOUT / _PROTOCOL parsed and reported, with fallbacks to the non-signal-specific OTEL_EXPORTER_OTLP_* variants. Only http/json is honored for the protocol. - All new configs flow through config telemetry like any other entry. Gates: - OTLP trace export is enabled iff OTEL_TRACES_EXPORTER=otlp. - DD_TRACE_AGENT_PROTOCOL_VERSION being set disables OTLP trace export (the agent trace protocol version takes precedence); a notice is logged. - Agent interaction (/info, Remote Config, telemetry) is unaffected: the OTLP traces endpoint is kept separate from the agent endpoint, exactly as the OTLP metrics endpoint already is. Sampler: - OTEL_TRACES_SAMPLER mapping to the DD sample rate now warns when a non-parentbased sampler is mapped to its parentbased equivalent. Wiring: - New Rust glue (components-rs): datadog_otel_traces_endpoint_from_url / _from_agent_url build the endpoint; ddog_sidecar_session_set_otlp_traces_endpoint / _clear register the resolved endpoint/headers/timeout per session. - ext/sidecar.c forwards the resolved OTLP traces endpoint to the sidecar in dd_sidecar_post_connect, alongside the OTLP metrics endpoint. Note: the libdatadog submodule is intentionally not modified. The sidecar's trace flush path (TraceFlusher/SendData to the agent endpoint) and the ddog_sidecar_session_set_config SessionConfig live in libdatadog and would need changes there to consume the registered OTLP traces endpoint via the OTLP TraceExporter. This change delivers the complete extension-side config plumbing and the FFI surface to carry the endpoint to the sidecar. Tests: - Rust unit tests for the endpoint builders and the session-config registry (components-rs). - .phpt tests: OTEL_TRACES_EXPORTER=otlp selection, endpoint fallback, explicit endpoint/headers/timeout/protocol, the DD_TRACE_AGENT_PROTOCOL_VERSION disable gate, and exporter=none. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Connect the extension's resolved OTLP traces config to libdatadog's new sidecar OTLP path, replacing the dead-end process-local OTLP_TRACES_CONFIG registry that the prior groundwork wired but never consumed. - ext/sidecar.c: in dd_sidecar_post_connect, build the OTLP traces ddog_Endpoint (datadog_otel_traces_endpoint) when OTLP trace export is enabled and pass it, with headers/timeout, into the new libdatadog FFI ddog_sidecar_session_set_otlp_traces_endpoint(transport, ...). A NULL endpoint clears the config and keeps the default agent path. Mirrors the OTLP metrics endpoint plumbing. - components-rs/sidecar.rs: remove the dead-end OtlpTracesConfig registry and the old URL-based ddog_sidecar_session_set/clear_otlp_traces_endpoint stubs; the real symbol now comes from datadog-sidecar-ffi. - ext/endpoints.c/.h: drop the now-unused datadog_otel_traces_url helper; the endpoint builder (datadog_otel_traces_endpoint) is what the sidecar FFI needs. - Bump libdatadog submodule to the matching OTLP TraceExporter commit. - Regenerate components-rs headers (cbindgen 0.29.0 + dedup): sidecar.h gains the new FFI declaration; datadog.h drops the removed stubs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bumps the libdatadog gitlink to pick up the OTLP encoder fallback that derives `deployment.environment.name` / `service.version` resource attributes from span meta for the sidecar OTLP traces path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…notice - Warn when OTEL_TRACES_EXPORTER=otlp is set but the OTLP traces endpoint can't be resolved (was a silent fallback to the agent path). - Warn on a configured non-http/json OTLP protocol (only http/json is supported this phase), matching dd-trace-rs/rb, so it isn't a silent no-op. - Clamp a negative OTEL_EXPORTER_OTLP_TRACES_TIMEOUT to 0 (FFI default) instead of wrapping to a huge uint64. - Strengthen the agent-url endpoint test to assert Some rather than passing vacuously. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
This was referenced Jun 10, 2026
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
Adds OTLP trace export to dd-trace-php. When
OTEL_TRACES_EXPORTER=otlpis set, the extension resolves the OTLP traces endpoint/headers/timeout and passes them to the libdatadog sidecar, which exports this session's traces over OTLP http/json via libdatadog'sTraceExporterinstead of the Datadog agent MessagePack path. This mirrors the existing OTLP metrics plumbing.Configuration:
OTEL_TRACES_EXPORTER—otlpenables OTLP export;nonedisables tracingOTEL_EXPORTER_OTLP_TRACES_ENDPOINT→ fallbackOTEL_EXPORTER_OTLP_ENDPOINT+/v1/traces→ defaulthttp://<agent_host>:4318/v1/tracesOTEL_EXPORTER_OTLP_TRACES_HEADERS/_TIMEOUT(10s) /_PROTOCOL(onlyhttp/jsonhonored this phase; warns otherwise)Behavior:
DD_TRACE_AGENT_PROTOCOL_VERSIONdisables OTLP; only sampled spans are exported (libdatadogdrop_chunks); the agent path (and Remote Config) is unchanged when OTLP is off.Reviewer checklist
Tests: extension-side config plumbing + the libdatadog FFI wiring;
.phpttests undertests/ext/otlp_traces_*.phpt; the Rust glue (components-rs) builds and unit-tests pass. Full.phptend-to-end + extension build run in CI. End-to-end coverage added in system-tests (Test_Otel_Tracing_OTLP, activated for php). Scope is RFC "OTLP Traces Export 2026Q1" Phase 1 (http/json only).Related PRs (cross-language OTLP traces export):
Merge order: libdatadog #2101 → dd-trace-php #3971 (re-bump the submodule to the released libdatadog commit). system-tests #7121 validates rust/ruby/php once the tracer branches are available.
🤖 Generated with Claude Code