feat(data-pipeline): propagate session ids through telemetry FFI#1908
feat(data-pipeline): propagate session ids through telemetry FFI#1908khanayan123 wants to merge 1 commit intomainfrom
Conversation
Extends the libdd-data-pipeline telemetry plumbing so SDKs that consume the trace-exporter FFI (dd-trace-dotnet, dd-trace-py, etc.) can attach the stable session correlation headers that #1817 added to libdd-telemetry. Before this change the session ids terminated at the libdd-telemetry-ffi builder entry points and could not reach trace exporter consumers. - Add optional `session_id`, `root_session_id`, and `parent_session_id` fields to `libdd_data_pipeline::trace_exporter::TelemetryConfig`. - Expose matching `set_session_id` / `set_root_session_id` / `set_parent_session_id` setters on the pipeline-level `TelemetryClientBuilder`, which forward to `libdd_telemetry::config::Config`. - Wire the new `TelemetryConfig` fields through `TraceExporterBuilder::build` so they reach the spawned telemetry worker. - Extend the FFI `TelemetryClientConfig` struct and `ddog_trace_exporter_config_enable_telemetry` to accept the three new `CharSlice` fields; empty slices are treated as unset to keep the caller API permissive. - Add unit tests covering the setters and the FFI round-trip. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
📚 Documentation Check Results📦
|
🔒 Cargo Deny Results📦
|
Clippy Allow Annotation ReportComparing clippy allow annotations between branches:
Summary by Rule
Annotation Counts by File
Annotation Stats by Crate
About This ReportThis 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. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1908 +/- ##
==========================================
+ Coverage 71.74% 71.80% +0.05%
==========================================
Files 434 434
Lines 69940 70033 +93
==========================================
+ Hits 50181 50284 +103
+ Misses 19759 19749 -10
🚀 New features to boost your workflow:
|
🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: c612fcd | Docs | Datadog PR Page | Give us feedback! |
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
mabdinur
left a comment
There was a problem hiding this comment.
I opened this PR a few weeks ago. Should we close it? https://github.com/DataDog/libdatadog/pull/1822/changes
What does this PR do?
Extends
libdd-data-pipelineandlibdd-data-pipeline-ffiso SDKs that drive telemetry through the trace exporter (dd-trace-dotnet, dd-trace-py, …) can attach the stable session correlation headers introduced forlibdd-telemetryin #1817.Concretely:
libdd_data_pipeline::trace_exporter::TelemetryConfiggains three optional fields:session_id,root_session_id,parent_session_id.libdd_data_pipeline::telemetry::TelemetryClientBuildergainsset_session_id/set_root_session_id/set_parent_session_idsetters mirroring the existingset_runtime_idpattern. Values are written onto the embeddedlibdd_telemetry::config::Configso the worker emits the correspondingDD-Session-ID/DD-Root-Session-ID/DD-Parent-Session-IDHTTP headers added in chore(telemetry): add session id support #1817.TraceExporterBuilder::buildforwards the newTelemetryConfigfields to the pipeline builder when telemetry is enabled.libdd_data_pipeline_ffi::trace_exporter::TelemetryClientConfig(the FFI struct passed toddog_trace_exporter_config_enable_telemetry) gains threeCharSlicefields. Empty slices are treated as unset so callers that don't need these IDs can leave them zero-initialized.Payload JSON is unchanged — the correlation IDs are HTTP headers only, matching the semantics already established by #1817.
Motivation
#1817 wired session correlation into
libdd-telemetryand exposed it throughlibdd-telemetry-ffi. SDKs that consume telemetry directly (sidecar path) can already set these IDs. SDKs that consume telemetry indirectly via the trace exporter (ddog_trace_exporter_config_enable_telemetry) cannot — the two FFI surfaces are separate, andlibdd-data-pipeline's internalTelemetryClientBuildernever exposed the setters.This is the blocker for dd-trace-dotnet's
DD_TRACE_DATA_PIPELINE_ENABLED=truecode path to emit the headers that its managed transport already emits from dd-trace-dotnet#8352. A companion dd-trace-dotnet PR will consume this once it ships.How to test
New tests:
libdd_data_pipeline::telemetry::tests::builder_session_ids_test— setters write through toconfig.libdd_data_pipeline::telemetry::tests::builder_session_ids_unset_by_default_test— defaults remainNone.libdd_data_pipeline_ffi::trace_exporter::tests::config_telemetry_session_ids_test— FFI round-tripsCharSliceIDs intoTelemetryConfig.config_telemetry_testextended to assert that emptyCharSlicefields stayNone.Additional Notes
#[repr(C)]TelemetryClientConfigstruct is a size/layout change. Consumers (dd-trace-dotnet, dd-trace-py, etc.) will need to rebuild against the new header. No source-level break for callers that use field-named initializers once they add the new fields; empty-slice defaults keep them effectively opt-in.DD-Parent-Session-ID: plumbed through for parity with libdd-telemetry. Whether a given SDK emits it is up to the SDK.Tracer.RuntimeId/RuntimeId.GetRootSessionId()on theDataPipelineEnabled=truepath.🤖 Generated with Claude Code