Skip to content

feat(process-tags): Service Override Source Attribution#3948

Draft
Leiyks wants to merge 4 commits into
masterfrom
leiyks/svc-override-source-attribution
Draft

feat(process-tags): Service Override Source Attribution#3948
Leiyks wants to merge 4 commits into
masterfrom
leiyks/svc-override-source-attribution

Conversation

@Leiyks
Copy link
Copy Markdown
Contributor

@Leiyks Leiyks commented Jun 3, 2026

Summary

Implements the RFC "Service Override Source Attribution" for the PHP tracer.

Every span whose service was actively chosen (vs. the tracer's default) now carries a _dd.svc_src meta tag identifying the source. Cleared for the default case (DD_SERVICE-set or auto-resolved).

Sources emitted (per RFC categories)

Source Value Where
Integration override <integration_name> Integration::handleInternalSpanServiceName (auto-covers Curl, Guzzle, PDO, Mysqli, SQLSRV, MongoDB, Memcached, AMQP, Kafka, …)
Config-driven (split-by) opt.http_client_split_by_domain Curl, Guzzle, Psr18, Ratchet
opt.db_client_split_by_instance PDO, Mysqli, SQLSRV
opt.redis_client_split_by_host PHPRedis
Framework root-span <integration_name> (only when DD_SERVICE is not user-set) Laravel, LaravelQueue, Drupal, Laminas, Lumen, Slim, SymfonyMessenger, Roadrunner, Ratchet web mode, CakePHP — via new Integration::tagFrameworkServiceSource helper
Manual API m C-side fallback in ddtrace_serialize_span_to_rust_span when span's service differs from root's and no other source tag was set
Default (DD_SERVICE or auto) not set Per RFC — cleared

…svc_src)

Implements the RFC "Service Override Source Attribution": tags every span
whose service was actively chosen (vs. tracer's default) with a
`_dd.svc_src` meta value identifying the source. Cleared for the default
case (DD_SERVICE-set or auto-resolved).

Sources emitted, per RFC categories:
- `<integration_name>` — when the integration sets the service (Curl,
  Guzzle, PDO, Mysqli, SQLSRV, MongoDB, Memcached, AMQP, Kafka, ... via
  `Integration::handleInternalSpanServiceName`)
- `opt.<option>` — when a config-driven split changes the service:
  * `opt.http_client_split_by_domain` (Curl, Guzzle, Psr18, Ratchet)
  * `opt.db_client_split_by_instance` (PDO, Mysqli, SQLSRV)
  * `opt.redis_client_split_by_host` (PHPRedis)
- Framework root-span overrides (Laravel, LaravelQueue, Drupal, Laminas,
  Lumen, Slim, SymfonyMessenger, Roadrunner, Ratchet web mode, CakePHP)
  use the new `Integration::tagFrameworkServiceSource` helper: cleared
  when user-set DD_SERVICE drove the value, else tagged with the
  integration name.
- `m` — manual API override at serialization-time fallback in
  `ddtrace_serialize_span_to_rust_span` when the span's service differs
  from the root's and no other tag was set.

Inheritance per RFC: `ddtrace_inherit_span_properties` copies
`_dd.svc_src` from parent meta at span creation; no back-propagation.

Tests:
- 3 new `.phpt` covering default-cleared, manual `'m'`, and parent->child
  inheritance.
- Existing `.phpt` expectations updated where manual service overrides
  now correctly emit `_dd.svc_src = 'm'`.

Out of scope (follow-up):
- Predis SPLIT_BY_HOST: stores service via meta override
  (`service.name`) rather than `$span->service`. Different mechanism;
  worth a separate discussion.

Refs RFC "Service Override Source Attribution".
@Leiyks Leiyks changed the title feat(process-tags): per-RFC Service Override Source Attribution feat(process-tags): Service Override Source Attribution Jun 3, 2026
@datadog-datadog-prod-us1-2
Copy link
Copy Markdown

datadog-datadog-prod-us1-2 Bot commented Jun 3, 2026

Pipelines  Tests

Fix all issues with BitsAI

⚠️ Warnings

🚦 658 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-php | test_web_cakephp_310: [7.2, cgi-fcgi]   View in Datadog   GitLab

See error 6 failed tests due to missing tag '_dd.svc_src' in spans.

🧪 6 Tests failed

testScenario with data set &#34;A GET request to a route with a parameter&#34; from cakephp-310-test.DDTrace\Tests\Integrations\CakePHP\V3_10\CommonScenariosTest.DDTrace\Tests\Integrations\CakePHP\V3_10\CommonScenariosTest::testScenario   View in Datadog (Fix with Cursor)
DDTrace\Tests\Integrations\CakePHP\V3_10\CommonScenariosTest::testScenario with data set &#34;A GET request to a route with a parameter&#34; (DDTrace\Tests\Frameworks\Util\Request\GetSpec Object (...), array(DDTrace\Tests\Common\SpanAssertion Object (...)))
cakephp.request: Expected tag name _dd.svc_src not found
Failed asserting that an array has the key &#39;_dd.svc_src&#39;.
Received Spans graph:
cakephp.request (service: cakephp_test_app, resource: GET ParameterizedController@customAction, type: web)
  runtime-id =&gt; 0bbe58c5-cb3e-4f49-8074-64026a43c965
  span.kind =&gt; server
  http.method =&gt; GET
  cakephp.route.controller =&gt; Parameterized
  http.url =&gt; http://localhost/parameterized/paramValue
...
testScenario with data set &#34;A GET request with an exception&#34; from cakephp-310-test.DDTrace\Tests\Integrations\CakePHP\V3_10\CommonScenariosTest.DDTrace\Tests\Integrations\CakePHP\V3_10\CommonScenariosTest::testScenario   View in Datadog (Fix with Cursor)
DDTrace\Tests\Integrations\CakePHP\V3_10\CommonScenariosTest::testScenario with data set &#34;A GET request with an exception&#34; (DDTrace\Tests\Frameworks\Util\Request\GetSpec Object (...), array(DDTrace\Tests\Common\SpanAssertion Object (...)))
cakephp.request: Expected tag name _dd.svc_src not found
Failed asserting that an array has the key &#39;_dd.svc_src&#39;.
Received Spans graph:
cakephp.request (service: cakephp_test_app, resource: GET ErrorController@index, type: web)
  error.stack =&gt; #0 tests/Frameworks/CakePHP/Version_3_10/vendor/cakephp/cakephp/src/Controller/Controller.php(606): App\Controller\ErrorController-&gt;index()
#1 tests/Frameworks/CakePHP/Version_3_10/vendor/cakephp/cakephp/src/Http/ActionDispatcher.php(120): Cake\Controller\Controller-&gt;invokeAction()
#2 tests/Frameworks/CakePHP/Version_3_10/vendor/cakephp/cakephp/src/Http/ActionDispatcher.php(94): Cake\Http\ActionDispatcher-&gt;_invoke()
#3 tests/Frameworks/CakePHP/Version_3_10/vendor/cakephp/cakephp/src/Http/BaseApplication.php(256): Cake\Http\ActionDispatcher-&gt;dispatch()
#4 tests/Frameworks/CakePHP/Version_3_10/vendor/cakephp/cakephp/src/Http/Runner.php(65): Cake\Http\BaseApplication-&gt;__invoke()
...
View all 6 test failures

DataDog/apm-reliability/dd-trace-php | test_web_cakephp_45: [8.1, apache2handler]   View in Datadog   GitLab

See error 6 failed tests due to missing '_dd.svc_src' tag in span assertions.

🧪 6 Tests failed

testScenario with data set &#34;A GET request to a route with a parameter&#34; from cakephp-45-test.DDTrace\Tests\Integrations\CakePHP\V4_5\CommonScenariosTest.DDTrace\Tests\Integrations\CakePHP\V4_5\CommonScenariosTest::testScenario   View in Datadog (Fix with Cursor)
DDTrace\Tests\Integrations\CakePHP\V4_5\CommonScenariosTest::testScenario with data set &#34;A GET request to a route with a parameter&#34; (DDTrace\Tests\Frameworks\Util\Request\GetSpec Object (...), array(DDTrace\Tests\Common\SpanAssertion Object (...)))
cakephp.request: Expected tag name _dd.svc_src not found
Failed asserting that an array has the key &#39;_dd.svc_src&#39;.
Received Spans graph:
cakephp.request (service: cakephp_test_app, resource: GET ParameterizedController@customAction, type: web)
  http.route =&gt; /parameterized/{param}
  http.status_code =&gt; 200
  runtime-id =&gt; 1803f4aa-ed5e-4fa9-bc5a-06628ba2abf3
  cakephp.route.controller =&gt; Parameterized
  http.url =&gt; http://localhost/parameterized/paramValue
...
testScenario with data set &#34;A GET request with an exception&#34; from cakephp-45-test.DDTrace\Tests\Integrations\CakePHP\V4_5\CommonScenariosTest.DDTrace\Tests\Integrations\CakePHP\V4_5\CommonScenariosTest::testScenario   View in Datadog (Fix with Cursor)
DDTrace\Tests\Integrations\CakePHP\V4_5\CommonScenariosTest::testScenario with data set &#34;A GET request with an exception&#34; (DDTrace\Tests\Frameworks\Util\Request\GetSpec Object (...), array(DDTrace\Tests\Common\SpanAssertion Object (...)))
cakephp.request: Expected tag name _dd.svc_src not found
Failed asserting that an array has the key &#39;_dd.svc_src&#39;.
Received Spans graph:
cakephp.request (service: cakephp_test_app, resource: GET ErrorController@index, type: web)
  http.url =&gt; http://localhost/error?key=value&amp;&lt;redacted&gt;
  component =&gt; cakephp
  cakephp.route.action =&gt; index
  http.route =&gt; /{controller}
  http.status_code =&gt; 500
...
View all 6 test failures

DataDog/apm-reliability/dd-trace-php | test_web_cakephp_latest: [8.1, apache2handler]   View in Datadog   GitLab

See error 6 failed tests related to missing '_dd.svc_src' tag in span assertions.

🧪 2 Tests failed

testScenario with data set &#34;A GET request to a route with a parameter&#34; from cakephp-latest-test.DDTrace\Tests\Integrations\CakePHP\Latest\CommonScenariosTest.DDTrace\Tests\Integrations\CakePHP\Latest\CommonScenariosTest::testScenario   View in Datadog (Fix with Cursor)
DDTrace\Tests\Integrations\CakePHP\Latest\CommonScenariosTest::testScenario with data set &#34;A GET request to a route with a parameter&#34; (DDTrace\Tests\Frameworks\Util\Request\GetSpec Object (...), array(DDTrace\Tests\Common\SpanAssertion Object (...)))
cakephp.request: Expected tag name _dd.svc_src not found
Failed asserting that an array has the key &#39;_dd.svc_src&#39;.
Received Spans graph:
cakephp.request (service: cakephp_test_app, resource: GET ParameterizedController@customAction, type: web)
  runtime-id =&gt; 236b07c2-8a6b-4e71-b5e3-2fdb86040b4c
  http.route =&gt; /parameterized/{param}
  http.method =&gt; GET
  http.url =&gt; http://localhost/parameterized/paramValue
  span.kind =&gt; server
...
testScenario with data set &#34;A GET request with an exception&#34; from cakephp-latest-test.DDTrace\Tests\Integrations\CakePHP\Latest\CommonScenariosTest.DDTrace\Tests\Integrations\CakePHP\Latest\CommonScenariosTest::testScenario   View in Datadog (Fix with Cursor)
DDTrace\Tests\Integrations\CakePHP\Latest\CommonScenariosTest::testScenario with data set &#34;A GET request with an exception&#34; (DDTrace\Tests\Frameworks\Util\Request\GetSpec Object (...), array(DDTrace\Tests\Common\SpanAssertion Object (...)))
cakephp.request: Expected tag name _dd.svc_src not found
Failed asserting that an array has the key &#39;_dd.svc_src&#39;.
Received Spans graph:
cakephp.request (service: cakephp_test_app, resource: GET ErrorController@index, type: web)
  runtime-id =&gt; 47da2213-6f3c-48ef-a2bb-dcfdb8f22daa
  http.url =&gt; http://localhost/error?key=value&amp;&lt;redacted&gt;
  error.type =&gt; Exception
  cakephp.route.action =&gt; index
  component =&gt; cakephp
...

View all 658 failed jobs.

🧪 6 Tests failed

    ❄️ Known flaky: testScenario with data set &#34;A GET request to a route with a parameter&#34; from cakephp-28-test.DDTrace\Tests\Integrations\CakePHP\V2_8\CommonScenariosTest.DDTrace\Tests\Integrations\CakePHP\V2_8\CommonScenariosTest::testScenario (Fix with Cursor)

    ❄️ Known flaky: testScenario with data set &#34;A GET request with an exception&#34; from cakephp-28-test.DDTrace\Tests\Integrations\CakePHP\V2_8\CommonScenariosTest.DDTrace\Tests\Integrations\CakePHP\V2_8\CommonScenariosTest::testScenario (Fix with Cursor)

View all 6 test failures

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

🔄 Datadog auto-retried 63 jobs - 0 passed on retry View in Datadog

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 54.12% (+0.00%)

Useful? React with 👍 / 👎

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

Leiyks added 3 commits June 3, 2026 17:05
Mirrors the existing pattern for _dd.p.dm / _dd.p.ksr / _dd.p.tid /
runtime-id / _dd.code_origin.*: when not explicitly asserted, drop
_dd.svc_src from the strict "extra tags" check so per-integration
test suites don't need every test updated.

Fixes 14 Memcache (and similar) integration-test failures on CI.
…lock

For each `Tag::COMPONENT => '<name>'` entry across the PHPUnit
integration suite, inject `'_dd.svc_src' => '<same value>'` so the
RFC contract is verified explicitly per test (instead of being
filtered out at the SpanChecker level).

Mechanical, 576 sites across 94 test files. Catches drift between
the integration's NAME constant and what shows up on spans.

(Reverts the SpanChecker filter from 89d443e; this is the
proper-per-test enforcement the senior asked for.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant