Skip to content

fix: Orphans not being sampled-out#2550

Merged
PROFeNoM merged 14 commits intomasterfrom
alex/fix/orphans
Mar 7, 2024
Merged

fix: Orphans not being sampled-out#2550
PROFeNoM merged 14 commits intomasterfrom
alex/fix/orphans

Conversation

@PROFeNoM
Copy link
Copy Markdown
Contributor

@PROFeNoM PROFeNoM commented Mar 1, 2024

Description

🚨 Requires #2556 🚨

What's the issue?

While doing some tests locally on my Laravel App, some orphan spans wouldn't get sampled away while they were in previous tracer versions.

What's happening?

In real life (i.e., not in our tests), the default fallback rule (service: , env: ) would get evaluated. This rule exists because of the default agent sampling rate of 10 traces per second. Most notably, when the rate per service would become 0, then \DDTrace\get_priority_sampling() would evaluate to zero, and we wouldn't set the priority sampling to auto reject again.

What's the fix?

The fix adds the check || $prioritySampling == DD_TRACE_PRIORITY_SAMPLING_AUTO_REJECT to the rejection condition.

While still not entirely realistic, the tests aim to assess that the code used to handle orphans works across values of agent sampling that would be evaluated through the default fallback rule.


Additionally, there were two additional mysqli_query spans in one test from this PR. Let's just test what we want actually to test.

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

@PROFeNoM PROFeNoM added the 🐛 bug Something isn't working label Mar 1, 2024
@PROFeNoM PROFeNoM self-assigned this Mar 1, 2024
@PROFeNoM PROFeNoM marked this pull request as ready for review March 1, 2024 14:05
@PROFeNoM PROFeNoM requested a review from a team as a code owner March 1, 2024 14:05
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 1, 2024

Codecov Report

❌ Patch coverage is 96.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 75.91%. Comparing base (dc24c31) to head (4f2ee25).
⚠️ Report is 841 commits behind head on master.

Files with missing lines Patch % Lines
...grations/Integrations/Predis/PredisIntegration.php 83.33% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2550      +/-   ##
============================================
- Coverage     77.08%   75.91%   -1.18%     
+ Complexity     2574     2563      -11     
============================================
  Files           214      241      +27     
  Lines         23057    27020    +3963     
  Branches          0      976     +976     
============================================
+ Hits          17773    20511    +2738     
- Misses         5284     5989     +705     
- Partials          0      520     +520     
Flag Coverage Δ
appsec-extension 69.13% <ø> (?)
tracer-extension 78.70% <ø> (ø)
tracer-php 75.06% <96.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ations/Integrations/Laravel/LaravelIntegration.php 81.90% <100.00%> (-0.03%) ⬇️
...ions/Integrations/PHPRedis/PHPRedisIntegration.php 97.89% <100.00%> (-0.04%) ⬇️
src/Integrations/Util/Common.php 100.00% <100.00%> (ø)
...grations/Integrations/Predis/PredisIntegration.php 86.29% <83.33%> (-0.64%) ⬇️

... and 26 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dc24c31...4f2ee25. Read the comment docs.

🚀 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.

@pr-commenter
Copy link
Copy Markdown

pr-commenter Bot commented Mar 1, 2024

Benchmarks

Benchmark execution time: 2024-03-05 14:22:30

Comparing candidate commit 4f2ee25 in PR branch alex/fix/orphans with baseline commit dc24c31 in branch master.

Found 0 performance improvements and 4 performance regressions! Performance is the same for 178 metrics, 0 unstable metrics.

scenario:PDOBench/benchPDOBaseline-opcache

  • 🟥 execution_time [+9.261µs; +16.992µs] or [+5.413%; +9.933%]

scenario:PDOBench/benchPDOOverhead-opcache

  • 🟥 execution_time [+17.500µs; +19.501µs] or [+6.319%; +7.042%]

scenario:PDOBench/benchPDOOverheadWithDBM-opcache

  • 🟥 execution_time [+19.082µs; +22.661µs] or [+6.253%; +7.425%]
  • 🟥 mem_peak [+77.896KB; +77.896KB] or [+3.456%; +3.456%]


class Common
{
// When modifying this method, please also pay attention to the tests/ext/orphans.phpt test and update it accordingly if needed.
Copy link
Copy Markdown
Collaborator

@bwoebi bwoebi Mar 1, 2024

Choose a reason for hiding this comment

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

Is there a reason why we cannot test that as part of an Integration test (isolated test testing Common::handleOrphan() directly is fine)? I'd rather avoid duplicating logic like this.
It also doesn't really fit in tests/ext as it's not testing the extension either, but testing how this particular code here interacts with functionality the extension provides.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I tried reaching out to the /next-response endpoint of the Request Replayer from TracerTestTrait, but it wouldn't work for w/e reason. I'm tempted to just use the capabilities offered by the test agent instead tbh

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Feel free to use that if it works :-)

@PROFeNoM PROFeNoM marked this pull request as draft March 5, 2024 11:10
@PROFeNoM PROFeNoM marked this pull request as ready for review March 5, 2024 12:28
Copy link
Copy Markdown
Collaborator

@bwoebi bwoebi left a comment

Choose a reason for hiding this comment

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

looks good to me now, thanks :-)

@PROFeNoM PROFeNoM merged commit 85997a2 into master Mar 7, 2024
@PROFeNoM PROFeNoM deleted the alex/fix/orphans branch March 7, 2024 11:01
@github-actions github-actions Bot added this to the 0.99.0 milestone Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working cat:integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants