-
Notifications
You must be signed in to change notification settings - Fork 173
Fix _dd.p.ksr scientific notation for very small sampling rates #3721
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c741ba4
Fix _dd.p.ksr scientific notation for very small sampling rates
bm1549 ce2a0e4
ci: retry CI
bm1549 422c890
Merge branch 'master' into brian.marks/fix-ksr-scientific-notation
bm1549 67b8312
Add tests for _dd.p.ksr rounding at 6-decimal boundary
bm1549 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
19 changes: 19 additions & 0 deletions
19
tests/ext/priority_sampling/029-ksr-tag-small-rate-formatting.phpt
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,19 @@ | ||
| --TEST-- | ||
| _dd.p.ksr uses decimal notation (not scientific) for very small sampling rates | ||
| --ENV-- | ||
| DD_TRACE_SAMPLING_RULES=[{"sample_rate": 0.000001}] | ||
| DD_TRACE_GENERATE_ROOT_SPAN=1 | ||
| --FILE-- | ||
| <?php | ||
| $root = \DDTrace\root_span(); | ||
|
|
||
| \DDTrace\get_priority_sampling(); | ||
|
|
||
| $ksr = isset($root->meta["_dd.p.ksr"]) ? $root->meta["_dd.p.ksr"] : "-"; | ||
| echo "_dd.p.ksr = ", $ksr, "\n"; | ||
| // Must be decimal notation, not scientific (e.g. "0.000001" not "1e-06") | ||
| echo "no_sci_notation = ", (strpos($ksr, 'e') === false) ? "true" : "false", "\n"; | ||
| ?> | ||
| --EXPECT-- | ||
| _dd.p.ksr = 0.000001 | ||
| no_sci_notation = true |
19 changes: 19 additions & 0 deletions
19
tests/ext/priority_sampling/030-ksr-tag-rounding-boundary.phpt
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,19 @@ | ||
| --TEST-- | ||
| _dd.p.ksr rounds small rates correctly at 6-decimal boundary | ||
| --ENV-- | ||
| DD_TRACE_SAMPLING_RULES=[{"sample_rate": 0.00000051}] | ||
| DD_TRACE_GENERATE_ROOT_SPAN=1 | ||
| --FILE-- | ||
| <?php | ||
| $root = \DDTrace\root_span(); | ||
|
|
||
| \DDTrace\get_priority_sampling(); | ||
|
|
||
| $ksr = isset($root->meta["_dd.p.ksr"]) ? $root->meta["_dd.p.ksr"] : "-"; | ||
| echo "_dd.p.ksr = ", $ksr, "\n"; | ||
| // 0.00000051 rounds up to 0.000001 at 6 decimal places | ||
| echo "no_sci_notation = ", (strpos($ksr, 'e') === false) ? "true" : "false", "\n"; | ||
| ?> | ||
| --EXPECT-- | ||
| _dd.p.ksr = 0.000001 | ||
| no_sci_notation = true |
18 changes: 18 additions & 0 deletions
18
tests/ext/priority_sampling/031-ksr-tag-exact-sixth-decimal.phpt
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,18 @@ | ||
| --TEST-- | ||
| _dd.p.ksr preserves exact 0.000001 rate without rounding away | ||
| --ENV-- | ||
| DD_TRACE_SAMPLING_RULES=[{"sample_rate": 0.000001}] | ||
| DD_TRACE_GENERATE_ROOT_SPAN=1 | ||
| --FILE-- | ||
| <?php | ||
| $root = \DDTrace\root_span(); | ||
|
|
||
| \DDTrace\get_priority_sampling(); | ||
|
|
||
| $ksr = isset($root->meta["_dd.p.ksr"]) ? $root->meta["_dd.p.ksr"] : "-"; | ||
| echo "_dd.p.ksr = ", $ksr, "\n"; | ||
| echo "no_sci_notation = ", (strpos($ksr, 'e') === false) ? "true" : "false", "\n"; | ||
| ?> | ||
| --EXPECT-- | ||
| _dd.p.ksr = 0.000001 | ||
| no_sci_notation = true |
19 changes: 19 additions & 0 deletions
19
tests/ext/priority_sampling/032-ksr-tag-below-precision-rounds-to-zero.phpt
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,19 @@ | ||
| --TEST-- | ||
| _dd.p.ksr rounds rate below 6-decimal precision to 0 | ||
| --ENV-- | ||
| DD_TRACE_SAMPLING_RULES=[{"sample_rate": 0.0000001}] | ||
| DD_TRACE_GENERATE_ROOT_SPAN=1 | ||
| --FILE-- | ||
| <?php | ||
| $root = \DDTrace\root_span(); | ||
|
|
||
| \DDTrace\get_priority_sampling(); | ||
|
|
||
| $ksr = isset($root->meta["_dd.p.ksr"]) ? $root->meta["_dd.p.ksr"] : "-"; | ||
| echo "_dd.p.ksr = ", $ksr, "\n"; | ||
| // 0.0000001 rounds to 0 at 6 decimal places | ||
| echo "no_sci_notation = ", (strpos($ksr, 'e') === false) ? "true" : "false", "\n"; | ||
| ?> | ||
| --EXPECT-- | ||
| _dd.p.ksr = 0 | ||
| no_sci_notation = true |
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.
Uh oh!
There was an error while loading. Please reload this page.