feat(sidecar): expose default_service_name for svc.* process tags#2053
feat(sidecar): expose default_service_name for svc.* process tags#2053Leiyks wants to merge 3 commits into
Conversation
Addresses senior review on the prior PR commit. Process tags are per-process (set once, propagated by the sidecar), but the active service name in PHP is request-local (mutable via `ini_set` and OTEL/RC fallbacks). Baking `svc.user`/`svc.auto` into the static process_tags string leaked the latest request's override into subsequent FPM requests. Two cooperating paths now: 1. **Per-span** (`ext/serializer.c::ddtrace_serialize_span_to_rust_span`): computes svc.user/svc.auto from `get_DD_SERVICE()` at serialization time and appends to that span's `_dd.tags.process`. Each span sees exactly its own request's state — no cross-request leak. 2. **Sidecar** (`ext/sidecar.c::ddtrace_sidecar_update_process_tags`): sends the process-level svc source to libdatadog via the new `ddog_sidecar_session_set_default_service_name` FFI. The sidecar injects svc.user/svc.auto into outgoing telemetry/RC/runtime_info payloads at emission time, eliminating the static-string conflict. The libdatadog half is in DataDog/libdatadog#2053; the submodule is bumped here to that commit. Reverts the static svc.* emission and `ddtrace_alter_dd_service` reload hook from 5a55f2d. Tests: - 5 new `.phpt` tests (CLI per-span correctness incl. ini_set + ini_restore) - New PHPUnit `testSvcTagDoesNotLeakBetweenRequests` against the FPM weblog: two sequential requests on the same worker prove svc.* reflects per-request state with no leak. Implements: RFC "Signal Service Name Source via Process Tags" https://docs.google.com/document/d/1c47iSTWxIOHMHfZTF2nT9xfyQaIBP9KJvI9sRn5SvpM
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. |
📚 Documentation Check Results📦
|
🔒 Cargo Deny Results📦
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2053 +/- ##
==========================================
- Coverage 72.92% 72.85% -0.07%
==========================================
Files 460 460
Lines 76463 76537 +74
==========================================
+ Hits 55758 55760 +2
- Misses 20705 20777 +72
🚀 New features to boost your workflow:
|
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 975e3af | Docs | Datadog PR Page | Give us feedback! |
Addresses review feedback on PR:
- Wrap `ddog_sidecar_session_set_default_service_name` calls in
`ddtrace_ffi_try` so transport errors surface in the trace log
instead of being silently dropped.
- Use `DDOG_CHARSLICE_C("")` instead of hand-rolled CharSlice struct
literal for the user-defined case (matches the rest of sidecar.c).
- Call `ddtrace_sidecar_update_process_tags()` at the end of
`ddtrace_sidecar_handle_fork` so the child's fresh sidecar session
re-learns the svc.* source after fork; without this, child
telemetry/RC/stats payloads would drop the svc.* tag entirely
until the next external trigger.
Submodule bump picks up the companion stats-payload fix in
DataDog/libdatadog#2053.
Adds `ddog_sidecar_session_set_default_service_name` so tracers can signal whether DD_SERVICE was user-set or auto-resolved (and the resolved name). The sidecar stores this per-session and injects `svc.user:true` or `svc.auto:<default>` into outgoing process-tags payloads (telemetry, remote config, runtime info), per RFC "Signal Service Name Source via Process Tags": https://docs.google.com/document/d/1c47iSTWxIOHMHfZTF2nT9xfyQaIBP9KJvI9sRn5SvpM The companion change in dd-trace-php (PR #3921) wires the new FFI and emits the per-span counterpart on traces directly.
Stats payloads were the one consumer not routed through `process_tags_with_svc_source()` because StatsConfig holds a pre-joined `String`. Two changes: - Build StatsConfig.process_tags from `session.process_tags_with_svc_source()` at construction time so concentrators created after the source is set carry svc.*. - Refresh StatsConfig.process_tags from both `set_session_process_tags` and `set_session_default_service_name` so live updates propagate. Addresses review feedback on initial PR.
5b35326 to
975e3af
Compare
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
|
Summary
Adds
ddog_sidecar_session_set_default_service_name(transport, default_service_name)so tracers can communicate whether the application's service name was user-set or tracer-auto-resolved.The sidecar stores this per-session and injects
svc.user:trueorsvc.auto:<default>into outgoing payloads (telemetry, remote config, runtime info) at emission time — eliminating the need for tracers to bake svc.* into their static process_tags string (which would conflict with request-local service mutations in languages like PHP).Implements the sidecar half of the RFC "Signal Service Name Source via Process Tags".
FFI
default_service_name→ServiceNameSource::UserDefined→ sidecar emitssvc.user:truedefault_service_name(pre-normalized viaddog_normalize_process_tag_value) →ServiceNameSource::AutoResolved(name)→ sidecar emitssvc.auto:<name>Internals
ServiceNameSourceenum inservice/mod.rsArc<Mutex<Option<ServiceNameSource>>>field onSessionInfoSessionInfo::process_tags_with_svc_source()helper — single source of truth used by all consumers of session process_tags (telemetry, RC, runtime_info, sidecar_server)set_session_process_tagsCompanion PR
DataDog/dd-trace-php#3921 — PHP tracer wires
ddog_sidecar_session_set_default_service_nameinext/sidecar.cand bumps the submodule to a commit including this change.