Skip to content

Commit

Permalink
Fix global priority sampling
Browse files Browse the repository at this point in the history
The global priority sampling was not recognized as explicit sampling and thus ignored.

Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
  • Loading branch information
bwoebi committed Jun 21, 2024
1 parent 59d1238 commit 646eeec
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ext/serializer.c
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,9 @@ void ddtrace_set_root_span_properties(ddtrace_root_span_data *span) {
if (DDTRACE_G(propagated_priority_sampling) != DDTRACE_PRIORITY_SAMPLING_UNSET) {
ZVAL_LONG(&span->property_propagated_sampling_priority, DDTRACE_G(propagated_priority_sampling));
}
ZVAL_LONG(&span->property_sampling_priority, DDTRACE_G(default_priority_sampling));
if (DDTRACE_G(default_priority_sampling) != DDTRACE_PRIORITY_SAMPLING_UNKNOWN) {
ddtrace_set_priority_sampling_on_span(span, DDTRACE_G(default_priority_sampling), DD_MECHANISM_MANUAL);
}

ddtrace_integration *web_integration = &ddtrace_integrations[DDTRACE_INTEGRATION_WEB];
if (get_DD_TRACE_ANALYTICS_ENABLED() || web_integration->is_analytics_enabled()) {
Expand Down
18 changes: 18 additions & 0 deletions tests/ext/priority_sampling/manual_global_override.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--TEST--
Global explicitly set priority sampling must be respected
--ENV--
DD_TRACE_SAMPLE_RATE=0
DD_TRACE_GENERATE_ROOT_SPAN=0
--FILE--
<?php

\DDTrace\set_priority_sampling(1);

$root = \DDTrace\start_span();

echo "Sampling: ", \DDTrace\get_priority_sampling(), "\n";
echo "_dd.p.dm = {$root->meta["_dd.p.dm"]}\n";
?>
--EXPECT--
Sampling: 1
_dd.p.dm = -4

0 comments on commit 646eeec

Please sign in to comment.