Skip to content

feat(sidecar): expose default_service_name for svc.* process tags#2053

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 5 commits into
mainfrom
leiyks/sidecar-default-service-name
Jun 25, 2026
Merged

feat(sidecar): expose default_service_name for svc.* process tags#2053
gh-worker-dd-mergequeue-cf854d[bot] merged 5 commits into
mainfrom
leiyks/sidecar-default-service-name

Conversation

@Leiyks

@Leiyks Leiyks commented May 28, 2026

Copy link
Copy Markdown
Contributor

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:true or svc.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

ddog_MaybeError ddog_sidecar_session_set_default_service_name(
    struct ddog_SidecarTransport **transport,
    struct ddog_CharSlice default_service_name);
  • Empty default_service_nameServiceNameSource::UserDefined → sidecar emits svc.user:true
  • Non-empty default_service_name (pre-normalized via ddog_normalize_process_tag_value) → ServiceNameSource::AutoResolved(name) → sidecar emits svc.auto:<name>
  • Never called → no svc.* tag emitted (matches the RFC: "no conclusions should be drawn from the absence of both")

Internals

  • New ServiceNameSource enum in service/mod.rs
  • New Arc<Mutex<Option<ServiceNameSource>>> field on SessionInfo
  • New SessionInfo::process_tags_with_svc_source() helper — single source of truth used by all consumers of session process_tags (telemetry, RC, runtime_info, sidecar_server)
  • RPC method + outbox slot + sender method + blocking helper, mirroring set_session_process_tags

Companion PR

DataDog/dd-trace-php#3921 — PHP tracer wires ddog_sidecar_session_set_default_service_name in ext/sidecar.c and bumps the submodule to a commit including this change.

Leiyks added a commit to DataDog/dd-trace-php that referenced this pull request May 28, 2026
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
@github-actions

github-actions Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Clippy Allow Annotation Report

Comparing clippy allow annotations between branches:

  • Base Branch: origin/main
  • PR Branch: origin/leiyks/sidecar-default-service-name

Summary by Rule

Rule Base Branch PR Branch Change
expect_used 3 3 No change (0%)
unwrap_used 9 9 No change (0%)
Total 12 12 No change (0%)

Annotation Counts by File

File Base Branch PR Branch Change
datadog-sidecar/src/service/blocking.rs 1 1 No change (0%)
datadog-sidecar/src/service/runtime_info.rs 1 1 No change (0%)
datadog-sidecar/src/service/session_info.rs 1 1 No change (0%)
datadog-sidecar/src/service/sidecar_server.rs 6 6 No change (0%)
datadog-sidecar/src/service/telemetry.rs 3 3 No change (0%)

Annotation Stats by Crate

Crate Base Branch PR Branch Change
clippy-annotation-reporter 5 5 No change (0%)
datadog-ffe-ffi 1 1 No change (0%)
datadog-ipc 22 22 No change (0%)
datadog-live-debugger 4 4 No change (0%)
datadog-live-debugger-ffi 10 10 No change (0%)
datadog-profiling-replayer 4 4 No change (0%)
datadog-sidecar 45 45 No change (0%)
libdd-common 13 13 No change (0%)
libdd-common-ffi 12 12 No change (0%)
libdd-data-pipeline 6 6 No change (0%)
libdd-ddsketch 2 2 No change (0%)
libdd-dogstatsd-client 1 1 No change (0%)
libdd-profiling 13 13 No change (0%)
libdd-remote-config 3 3 No change (0%)
libdd-telemetry 20 20 No change (0%)
libdd-tinybytes 4 4 No change (0%)
libdd-trace-normalization 2 2 No change (0%)
libdd-trace-obfuscation 3 3 No change (0%)
libdd-trace-stats 1 1 No change (0%)
libdd-trace-utils 11 11 No change (0%)
Total 182 182 No change (0%)

About This Report

This 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-commenter

codecov-commenter commented May 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 2.50000% with 78 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.85%. Comparing base (b6188a8) to head (975e3af).

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     
Components Coverage Δ
libdd-crashtracker 65.37% <ø> (+0.01%) ⬆️
libdd-crashtracker-ffi 36.82% <ø> (ø)
libdd-alloc 98.77% <ø> (ø)
libdd-data-pipeline 85.65% <ø> (ø)
libdd-data-pipeline-ffi 76.17% <ø> (ø)
libdd-common 79.89% <ø> (ø)
libdd-common-ffi 74.41% <ø> (ø)
libdd-telemetry 73.34% <ø> (ø)
libdd-telemetry-ffi 31.36% <ø> (ø)
libdd-dogstatsd-client 82.64% <ø> (ø)
datadog-ipc 76.22% <ø> (ø)
libdd-profiling 81.68% <ø> (ø)
libdd-profiling-ffi 64.79% <ø> (ø)
libdd-sampling 97.46% <ø> (ø)
datadog-sidecar 28.88% <2.50%> (-0.31%) ⬇️
datdog-sidecar-ffi 10.06% <0.00%> (-0.12%) ⬇️
spawn-worker 48.86% <ø> (ø)
libdd-tinybytes 93.80% <ø> (ø)
libdd-trace-normalization 81.71% <ø> (ø)
libdd-trace-obfuscation 87.30% <ø> (ø)
libdd-trace-protobuf 68.25% <ø> (ø)
libdd-trace-utils 88.94% <ø> (ø)
libdd-tracer-flare 86.88% <ø> (ø)
libdd-log 74.83% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented May 28, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 2.91%
Overall Coverage: 73.94% (-0.10%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 50250cc | Docs | Datadog PR Page | Give us feedback!

Leiyks added a commit to DataDog/dd-trace-php that referenced this pull request May 28, 2026
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.
@Leiyks Leiyks force-pushed the leiyks/sidecar-default-service-name branch from 5b35326 to 975e3af Compare May 29, 2026 13:21
@dd-octo-sts

dd-octo-sts Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

Artifact Size Benchmark Report

aarch64-alpine-linux-musl
Artifact Baseline Commit Change
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 84.87 MB 84.87 MB 0% (0 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 7.82 MB 7.82 MB 0% (0 B) 👌
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.44 MB 10.44 MB 0% (0 B) 👌
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 96.00 MB 96.00 MB 0% (0 B) 👌
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 25.05 MB 25.05 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 87.68 KB 87.68 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 182.83 MB 182.80 MB --.01% (-24.00 KB) 💪
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 936.10 MB 936.10 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 8.20 MB 8.20 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 87.68 KB 87.68 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 24.23 MB 24.23 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 48.34 MB 48.34 MB 0% (0 B) 👌
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 21.71 MB 21.71 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 89.06 KB 89.06 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 186.80 MB 186.80 MB -0% (-8.00 KB) 👌
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 924.73 MB 924.73 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 6.33 MB 6.33 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 89.06 KB 89.06 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 25.99 MB 25.99 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 45.96 MB 45.96 MB 0% (0 B) 👌
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 75.64 MB 75.64 MB 0% (0 B) 👌
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 8.68 MB 8.68 MB 0% (0 B) 👌
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 91.09 MB 91.09 MB 0% (0 B) 👌
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.57 MB 10.57 MB 0% (0 B) 👌

Leiyks added a commit to DataDog/dd-trace-php that referenced this pull request Jun 2, 2026
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
Leiyks added a commit to DataDog/dd-trace-php that referenced this pull request Jun 2, 2026
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.
@Leiyks Leiyks force-pushed the leiyks/sidecar-default-service-name branch from 0ebc259 to 91436f4 Compare June 17, 2026 13:02
Leiyks added a commit to DataDog/dd-trace-php that referenced this pull request Jun 17, 2026
Implements the PHP-tracer side of RFC "Signal Service Name Source via
Process Tags". Surfaces one of two mutually-exclusive process tags so
the backend can distinguish user-set vs tracer-auto-resolved service
names:

- svc.user:true  — DD_SERVICE non-empty (env, INI, OTEL fallback, RC)
- svc.auto:<name> — DD_SERVICE empty; tracer auto-resolved the default

Per the RFC caveats, no conclusions are drawn from the absence of both.

## Per-span emission (traces) — tracer/serializer.c

In ddtrace_serialize_span_to_rust_span's is_first_span block, the
auto-resolved default name is read directly from the root span's
property_service when its _dd.svc_src is absent (Service Override
Source Attribution RFC: cleared svc_src ↔ service is the global
default), avoiding a second pass through datadog_default_service_name().
Each span sees its own request's state — no FPM cross-request leak.

## Sidecar (telemetry / remote config / runtime info) — ext/sidecar.c

datadog_sidecar_update_process_tags now also calls
ddog_sidecar_session_set_default_service_name(transport, …):

- Empty CharSlice → sidecar injects svc.user:true
- Normalized default → sidecar injects svc.auto:<default>

Injection happens at payload emission time in libdatadog (companion PR
DataDog/libdatadog#2053), so telemetry / remote-config / runtime-info /
stats payloads all see consistent svc.* tagging without baking it into
the static process_tags string.

## Tests

- New CLI .phpt tests covering svc.user, svc.auto, OTEL fallback as
  user-defined, and ini_set-driven runtime mutation.
- New web-SAPI test ProcessTagsWebTest::testSvcTagDoesNotLeakBetweenRequests
  proving the per-span design holds across FPM workers.
- Existing process_tags.phpt / telemetry_process_tags.phpt updated to
  expect the appended svc.auto tag.
@Leiyks Leiyks force-pushed the leiyks/sidecar-default-service-name branch from 32e3de1 to ba0146f Compare June 17, 2026 13:16
Leiyks added a commit to DataDog/dd-trace-php that referenced this pull request Jun 17, 2026
Implements the PHP-tracer side of RFC "Signal Service Name Source via
Process Tags". Surfaces one of two mutually-exclusive process tags so
the backend can distinguish user-set vs tracer-auto-resolved service
names:

- svc.user:true  — DD_SERVICE non-empty (env, INI, OTEL fallback, RC)
- svc.auto:<name> — DD_SERVICE empty; tracer auto-resolved the default

Per the RFC caveats, no conclusions are drawn from the absence of both.

In ddtrace_serialize_span_to_rust_span's is_first_span block, the
auto-resolved default name is read directly from the root span's
property_service when its _dd.svc_src is absent (Service Override
Source Attribution RFC: cleared svc_src ↔ service is the global
default), avoiding a second pass through datadog_default_service_name().
Each span sees its own request's state — no FPM cross-request leak.

datadog_sidecar_update_process_tags now also calls
ddog_sidecar_session_set_default_service_name(transport, …):

- Empty CharSlice → sidecar injects svc.user:true
- Normalized default → sidecar injects svc.auto:<default>

Injection happens at payload emission time in libdatadog (companion PR
DataDog/libdatadog#2053), so telemetry / remote-config / runtime-info /
stats payloads all see consistent svc.* tagging without baking it into
the static process_tags string.

- New CLI .phpt tests covering svc.user, svc.auto, OTEL fallback as
  user-defined, and ini_set-driven runtime mutation.
- New web-SAPI test ProcessTagsWebTest::testSvcTagDoesNotLeakBetweenRequests
  proving the per-span design holds across FPM workers.
- Existing process_tags.phpt / telemetry_process_tags.phpt updated to
  expect the appended svc.auto tag.
Leiyks added a commit to DataDog/dd-trace-php that referenced this pull request Jun 17, 2026
Implements the PHP-tracer side of RFC "Signal Service Name Source via
Process Tags". Surfaces one of two mutually-exclusive process tags so
the backend can distinguish user-set vs tracer-auto-resolved service
names:

- svc.user:true  — DD_SERVICE non-empty (env, INI, OTEL fallback, RC)
- svc.auto:<name> — DD_SERVICE empty; tracer auto-resolved the default

Per the RFC caveats, no conclusions are drawn from the absence of both.

In ddtrace_serialize_span_to_rust_span's is_first_span block, the
auto-resolved default name is read directly from the root span's
property_service when its _dd.svc_src is absent (Service Override
Source Attribution RFC: cleared svc_src ↔ service is the global
default), avoiding a second pass through datadog_default_service_name().
Each span sees its own request's state — no FPM cross-request leak.

datadog_sidecar_update_process_tags now also calls
ddog_sidecar_session_set_default_service_name(transport, …):

- Empty CharSlice → sidecar injects svc.user:true
- Normalized default → sidecar injects svc.auto:<default>

Injection happens at payload emission time in libdatadog (companion PR
DataDog/libdatadog#2053), so telemetry / remote-config / runtime-info /
stats payloads all see consistent svc.* tagging without baking it into
the static process_tags string.

- New CLI .phpt tests covering svc.user, svc.auto, OTEL fallback as
  user-defined, and ini_set-driven runtime mutation.
- New web-SAPI test ProcessTagsWebTest::testSvcTagDoesNotLeakBetweenRequests
  proving the per-span design holds across FPM workers.
- Existing process_tags.phpt / telemetry_process_tags.phpt updated to
  expect the appended svc.auto tag.
Leiyks added a commit to DataDog/dd-trace-php that referenced this pull request Jun 17, 2026
Implements the PHP-tracer side of RFC "Signal Service Name Source via
Process Tags". Surfaces one of two mutually-exclusive process tags so
the backend can distinguish user-set vs tracer-auto-resolved service
names:

- svc.user:true  — DD_SERVICE non-empty (env, INI, OTEL fallback, RC)
- svc.auto:<name> — DD_SERVICE empty; tracer auto-resolved the default

Per the RFC caveats, no conclusions are drawn from the absence of both.

In ddtrace_serialize_span_to_rust_span's is_first_span block, the
auto-resolved default name is read directly from the root span's
property_service when its _dd.svc_src is absent (Service Override
Source Attribution RFC: cleared svc_src ↔ service is the global
default), avoiding a second pass through datadog_default_service_name().
Each span sees its own request's state — no FPM cross-request leak.

datadog_sidecar_update_process_tags now also calls
ddog_sidecar_session_set_default_service_name(transport, …):

- Empty CharSlice → sidecar injects svc.user:true
- Normalized default → sidecar injects svc.auto:<default>

Injection happens at payload emission time in libdatadog (companion PR
DataDog/libdatadog#2053), so telemetry / remote-config / runtime-info /
stats payloads all see consistent svc.* tagging without baking it into
the static process_tags string.

- New CLI .phpt tests covering svc.user, svc.auto, OTEL fallback as
  user-defined, and ini_set-driven runtime mutation.
- New web-SAPI test ProcessTagsWebTest::testSvcTagDoesNotLeakBetweenRequests
  proving the per-span design holds across FPM workers.
- Existing process_tags.phpt / telemetry_process_tags.phpt updated to
  expect the appended svc.auto tag.
Leiyks added a commit to DataDog/dd-trace-php that referenced this pull request Jun 18, 2026
Implements the PHP-tracer side of RFC "Signal Service Name Source via
Process Tags". Surfaces one of two mutually-exclusive process tags so
the backend can distinguish user-set vs tracer-auto-resolved service
names:

- svc.user:true  — DD_SERVICE non-empty (env, INI, OTEL fallback, RC)
- svc.auto:<name> — DD_SERVICE empty; tracer auto-resolved the default

Per the RFC caveats, no conclusions are drawn from the absence of both.

In ddtrace_serialize_span_to_rust_span's is_first_span block, the
auto-resolved default name is read directly from the root span's
property_service when its _dd.svc_src is absent (Service Override
Source Attribution RFC: cleared svc_src ↔ service is the global
default), avoiding a second pass through datadog_default_service_name().
Each span sees its own request's state — no FPM cross-request leak.

datadog_sidecar_update_process_tags now also calls
ddog_sidecar_session_set_default_service_name(transport, …):

- Empty CharSlice → sidecar injects svc.user:true
- Normalized default → sidecar injects svc.auto:<default>

Injection happens at payload emission time in libdatadog (companion PR
DataDog/libdatadog#2053), so telemetry / remote-config / runtime-info /
stats payloads all see consistent svc.* tagging without baking it into
the static process_tags string.

- New CLI .phpt tests covering svc.user, svc.auto, OTEL fallback as
  user-defined, and ini_set-driven runtime mutation.
- New web-SAPI test ProcessTagsWebTest::testSvcTagDoesNotLeakBetweenRequests
  proving the per-span design holds across FPM workers.
- Existing process_tags.phpt / telemetry_process_tags.phpt updated to
  expect the appended svc.auto tag.
Comment thread datadog-sidecar/src/service/sidecar_interface.rs Outdated

@bwoebi bwoebi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@Leiyks Leiyks marked this pull request as ready for review June 25, 2026 15:17
@Leiyks Leiyks requested review from a team as code owners June 25, 2026 15:17

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ac68fdaf32

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

let env = entry.get().env.as_deref().unwrap_or("none");

let process_tags = session.process_tags.lock_or_panic().clone();
let process_tags = session.process_tags_with_svc_source();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Refresh cached telemetry tags when service source changes

When set_session_user_service_defined changes after a telemetry client already exists for the same service/env, this recomputed process_tags value is never applied: TelemetryCachedClientSet::get_or_create returns the existing client before using the argument, and TelemetryCachedClient::new is the only place that copies it into builder.application.process_tags. In a process that first reports svc.auto:<name> and later has DD_SERVICE set to the same service name, telemetry keeps using the stale svc.auto tag instead of svc.user:true until the client is removed.

Useful? React with 👍 / 👎.

Leiyks added 5 commits June 25, 2026 17:32
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.
…tent

The `Target` struct in datadog-remote-config derives Hash over all
fields including process_tags. Both the sidecar (RC write side) and
the tracer (RC read side via ddog_remote_configs_service_env_change)
must agree on the Target hash, and the tracer passes the bare
process_tags Vec.

Augmenting only the sidecar side with svc.* via
`process_tags_with_svc_source()` made the Target hashes diverge,
orphaning RC configs in SHM (probes never installed, dynamic config
never applied).

For now revert this single call site to bare process_tags. A proper
follow-up should either exclude process_tags from Target's Hash/Eq
impl, or separate Target's identity fields from the payload metadata
fields. Trace + telemetry svc.* injection is unaffected.
…defined flag

Addresses review feedback: DD_SERVICE is request-mutable, not session-bound.
The previous single FFI conflated the two facts (empty CharSlice meaning
"user-defined", non-empty meaning the auto-resolved name), which forced the
tracer to re-push state to the sidecar every time DD_SERVICE changed.

Split into two independent session fields:
- auto_resolved_service_name: Option<String> — process-stable, set once via
  ddog_sidecar_session_set_default_service_name(name).
- user_service_defined: bool — per-request mutable, refreshed via the new
  ddog_sidecar_session_set_user_service_defined(is_defined) on each RINIT.

process_tags_with_svc_source() now emits svc.user:true when user_service_defined
is true, else svc.auto:<name> when an auto-resolved name is stored. The old
ServiceNameSource enum is dropped.
@Leiyks Leiyks force-pushed the leiyks/sidecar-default-service-name branch from ac68fda to 50250cc Compare June 25, 2026 15:39
@Leiyks

Leiyks commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jun 25, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-06-25 15:54:35 UTC ℹ️ Start processing command /merge


2026-06-25 15:54:41 UTC ℹ️ MergeQueue: waiting for PR to be ready

This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
It will be added to the queue as soon as checks pass and/or get approvals. View in MergeQueue UI.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2026-06-25 16:43:10 UTC ℹ️ MergeQueue: merge request added to the queue

The expected merge time in main is approximately 1h (p90).


2026-06-25 18:43:32 UTCMergeQueue: The build pipeline has timeout

The merge request has been interrupted because the build 8394159919868547325 took longer than expected. The current limit for the base branch 'main' is 120 minutes.

@Leiyks

Leiyks commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jun 25, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-06-25 18:46:22 UTC ℹ️ Start processing command /merge


2026-06-25 18:46:27 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 1h (p90).


2026-06-25 19:52:29 UTC ℹ️ MergeQueue: This merge request was merged

@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit 6a6d4a5 into main Jun 25, 2026
173 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the leiyks/sidecar-default-service-name branch June 25, 2026 19:52
Leiyks added a commit to DataDog/dd-trace-php that referenced this pull request Jun 25, 2026
Implements the PHP-tracer side of RFC "Signal Service Name Source via
Process Tags". Surfaces one of two mutually-exclusive process tags so
the backend can distinguish user-set vs tracer-auto-resolved service
names:

- svc.user:true  — DD_SERVICE non-empty (env, INI, OTEL fallback, RC)
- svc.auto:<name> — DD_SERVICE empty; tracer auto-resolved the default

Per the RFC caveats, no conclusions are drawn from the absence of both.

In ddtrace_serialize_span_to_rust_span's is_first_span block, the
auto-resolved default name is read directly from the root span's
property_service when its _dd.svc_src is absent (Service Override
Source Attribution RFC: cleared svc_src ↔ service is the global
default), avoiding a second pass through datadog_default_service_name().
Each span sees its own request's state — no FPM cross-request leak.

datadog_sidecar_update_process_tags now also calls
ddog_sidecar_session_set_default_service_name(transport, …):

- Empty CharSlice → sidecar injects svc.user:true
- Normalized default → sidecar injects svc.auto:<default>

Injection happens at payload emission time in libdatadog (companion PR
DataDog/libdatadog#2053), so telemetry / remote-config / runtime-info /
stats payloads all see consistent svc.* tagging without baking it into
the static process_tags string.

- New CLI .phpt tests covering svc.user, svc.auto, OTEL fallback as
  user-defined, and ini_set-driven runtime mutation.
- New web-SAPI test ProcessTagsWebTest::testSvcTagDoesNotLeakBetweenRequests
  proving the per-span design holds across FPM workers.
- Existing process_tags.phpt / telemetry_process_tags.phpt updated to
  expect the appended svc.auto tag.
Leiyks added a commit to DataDog/dd-trace-php that referenced this pull request Jun 25, 2026
…3921)

* feat(process-tags): signal service name source via svc.user/svc.auto

Implements the PHP-tracer side of RFC "Signal Service Name Source via
Process Tags". Surfaces one of two mutually-exclusive process tags so
the backend can distinguish user-set vs tracer-auto-resolved service
names:

- svc.user:true  — DD_SERVICE non-empty (env, INI, OTEL fallback, RC)
- svc.auto:<name> — DD_SERVICE empty; tracer auto-resolved the default

Per the RFC caveats, no conclusions are drawn from the absence of both.

In ddtrace_serialize_span_to_rust_span's is_first_span block, the
auto-resolved default name is read directly from the root span's
property_service when its _dd.svc_src is absent (Service Override
Source Attribution RFC: cleared svc_src ↔ service is the global
default), avoiding a second pass through datadog_default_service_name().
Each span sees its own request's state — no FPM cross-request leak.

datadog_sidecar_update_process_tags now also calls
ddog_sidecar_session_set_default_service_name(transport, …):

- Empty CharSlice → sidecar injects svc.user:true
- Normalized default → sidecar injects svc.auto:<default>

Injection happens at payload emission time in libdatadog (companion PR
DataDog/libdatadog#2053), so telemetry / remote-config / runtime-info /
stats payloads all see consistent svc.* tagging without baking it into
the static process_tags string.

- New CLI .phpt tests covering svc.user, svc.auto, OTEL fallback as
  user-defined, and ini_set-driven runtime mutation.
- New web-SAPI test ProcessTagsWebTest::testSvcTagDoesNotLeakBetweenRequests
  proving the per-span design holds across FPM workers.
- Existing process_tags.phpt / telemetry_process_tags.phpt updated to
  expect the appended svc.auto tag.

* Apply suggestions from code review

Co-authored-by: Bob Weinand <bobwei9@hotmail.com>

* fix(svc_src): use datadog_convert_to_str + correct process_tags.phpt expectation

- serializer.c: drop the temp zval and use datadog_convert_to_str directly
  (zend_string out, released by caller) per review.
- process_tags.phpt: the test sets \$parent_span->service = 'test_service'
  manually, so the root span carries _dd.svc_src='m' (Service Override
  Source Attribution RFC); the per-span emission correctly skips svc.auto
  because the service isn't the global default. Remove the spurious
  svc.auto:process_tags.php from the expected output.

---------

Co-authored-by: Bob Weinand <bobwei9@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants