-
Notifications
You must be signed in to change notification settings - Fork 179
feat(process-tags): signal service name source via svc.user/svc.auto #3921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Leiyks
wants to merge
6
commits into
master
Choose a base branch
from
leiyks/svc-source-process-tags
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
64040f8
feat(process-tags): signal service name source via svc.user/svc.auto
Leiyks 602e778
feat(process-tags): emit svc.user/svc.auto per-span and via sidecar
Leiyks cdf7e03
fix(sidecar): wrap new FFI calls in ddtrace_ffi_try, refresh after fork
Leiyks a210c1c
chore: trim comments + bump libdatadog submodule
Leiyks 9a57ed0
fix(tests): update process_tags expectations for svc.auto sidecar inj…
Leiyks 84b004e
fix(process-tags): drop svc.* from RC/live-debugger payloads for now
Leiyks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Submodule libdatadog
updated
37 files
13 changes: 13 additions & 0 deletions
13
tests/Frameworks/Custom/Version_Autoloaded/src/SetServiceController.php
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <?php | ||
|
|
||
| namespace App; | ||
|
|
||
| class SetServiceController | ||
| { | ||
| public function render() | ||
| { | ||
| ini_set('datadog.service', 'request-svc'); | ||
| header('Content-type: text/plain; charset=utf-8'); | ||
| echo 'service set'; | ||
| } | ||
| } |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| --TEST-- | ||
| Process tags include svc.auto:<default> when DD_SERVICE is unset (CLI) | ||
| --ENV-- | ||
| DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED=1 | ||
| DD_TRACE_GENERATE_ROOT_SPAN=0 | ||
| DD_TRACE_AUTO_FLUSH_ENABLED=0 | ||
| --FILE-- | ||
| <?php | ||
| $span = \DDTrace\start_span(); | ||
| $span->name = 'op'; | ||
| \DDTrace\close_span(); | ||
|
|
||
| $spans = dd_trace_serialize_closed_spans(); | ||
| $processTags = $spans[0]['meta']['_dd.tags.process']; | ||
|
|
||
| echo "has svc.user: " . (strpos($processTags, 'svc.user') !== false ? 'YES' : 'NO') . "\n"; | ||
| echo "has svc.auto: " . (strpos($processTags, 'svc.auto:') !== false ? 'YES' : 'NO') . "\n"; | ||
| echo "auto value matches script: " . (strpos($processTags, 'svc.auto:svc_auto_tag_cli.php') !== false ? 'YES' : 'NO') . "\n"; | ||
| ?> | ||
| --EXPECT-- | ||
| has svc.user: NO | ||
| has svc.auto: YES | ||
| auto value matches script: YES |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| --TEST-- | ||
| OTEL_SERVICE_NAME counts as user-defined (emits svc.user:true) | ||
| --ENV-- | ||
| DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED=1 | ||
| OTEL_SERVICE_NAME=otel-app | ||
| DD_TRACE_GENERATE_ROOT_SPAN=0 | ||
| DD_TRACE_AUTO_FLUSH_ENABLED=0 | ||
| --FILE-- | ||
| <?php | ||
| $span = \DDTrace\start_span(); | ||
| $span->name = 'op'; | ||
| \DDTrace\close_span(); | ||
|
|
||
| $spans = dd_trace_serialize_closed_spans(); | ||
| $processTags = $spans[0]['meta']['_dd.tags.process']; | ||
|
|
||
| echo "DD_SERVICE resolved to: " . ini_get('datadog.service') . "\n"; | ||
| echo "has svc.user:true: " . (strpos($processTags, 'svc.user:true') !== false ? 'YES' : 'NO') . "\n"; | ||
| echo "has svc.auto: : " . (strpos($processTags, 'svc.auto:') !== false ? 'YES' : 'NO') . "\n"; | ||
| ?> | ||
| --EXPECT-- | ||
| DD_SERVICE resolved to: otel-app | ||
| has svc.user:true: YES | ||
| has svc.auto: : NO |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| --TEST-- | ||
| Changing datadog.service at runtime recomputes svc.user/svc.auto process tags per-span | ||
| --ENV-- | ||
| DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED=1 | ||
| DD_TRACE_GENERATE_ROOT_SPAN=0 | ||
| DD_TRACE_AUTO_FLUSH_ENABLED=0 | ||
| --FILE-- | ||
| <?php | ||
| function assert_tags($label) { | ||
| $spans = dd_trace_serialize_closed_spans(); | ||
| $tags = $spans[0]['meta']['_dd.tags.process']; | ||
| $hasUser = strpos($tags, 'svc.user:true') !== false; | ||
| $hasAuto = strpos($tags, 'svc.auto:') !== false; | ||
| echo "$label svc.user=" . ($hasUser ? 'YES' : 'NO') . " svc.auto=" . ($hasAuto ? 'YES' : 'NO') . "\n"; | ||
| } | ||
|
|
||
| $span1 = \DDTrace\start_span(); | ||
| $span1->name = 'before'; | ||
| \DDTrace\close_span(); | ||
| assert_tags('BEFORE '); | ||
|
|
||
| ini_set('datadog.service', 'changed-svc'); | ||
| $span2 = \DDTrace\start_span(); | ||
| $span2->name = 'after_set'; | ||
| \DDTrace\close_span(); | ||
| assert_tags('AFTER '); | ||
|
|
||
| ini_restore('datadog.service'); | ||
| $span3 = \DDTrace\start_span(); | ||
| $span3->name = 'after_restore'; | ||
| \DDTrace\close_span(); | ||
| assert_tags('REVERTED'); | ||
| ?> | ||
| --EXPECT-- | ||
| BEFORE svc.user=NO svc.auto=YES | ||
| AFTER svc.user=YES svc.auto=NO | ||
| REVERTED svc.user=NO svc.auto=YES |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| --TEST-- | ||
| Process tags include svc.user:true when DD_SERVICE is set | ||
| --ENV-- | ||
| DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED=1 | ||
| DD_SERVICE=my-app | ||
| DD_TRACE_GENERATE_ROOT_SPAN=0 | ||
| DD_TRACE_AUTO_FLUSH_ENABLED=0 | ||
| --FILE-- | ||
| <?php | ||
| $span = \DDTrace\start_span(); | ||
| $span->name = 'op'; | ||
| \DDTrace\close_span(); | ||
|
|
||
| $spans = dd_trace_serialize_closed_spans(); | ||
| $processTags = $spans[0]['meta']['_dd.tags.process']; | ||
|
|
||
| echo "has svc.user:true: " . (strpos($processTags, 'svc.user:true') !== false ? 'YES' : 'NO') . "\n"; | ||
| echo "has svc.auto: : " . (strpos($processTags, 'svc.auto:') !== false ? 'YES' : 'NO') . "\n"; | ||
| ?> | ||
| --EXPECT-- | ||
| has svc.user:true: YES | ||
| has svc.auto: : NO |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DD_SERVICE is dynamic per request, not per session.
Some request may have it, another not.
You probably can store ddtrace_default_service_name() on the sidecar as session bound (at which point setting that one via ddog_sidecar_session_set_config is enough), but the DD_SERVICE may or may not exist for any particular request, and change between requests. You may have to submit that one alongside with ddog_sidecar_set_universal_service_tags().
... let's talk about that?!