Skip to content
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

feat: delay sampling decision to allow sampling on tags and resource #3956

Merged
merged 38 commits into from
Oct 7, 2024

Conversation

ZStriker19
Copy link
Contributor

@ZStriker19 ZStriker19 commented Sep 25, 2024

What does this PR do?
This PR enables lazy sampling with the feature being the ability to sample on tags and resource values for root spans. It does this by:

  1. Removing sampling at span start
  2. Change the metadata values returned by TraceOperation so that values from the root span will be returned if available, allowing sampling on all tags that will end up attached to the root span.
  3. Running sampling in TraceOperation.to_digest which runs before context propagation
  4. Running sampling in Tracer.flush which runs before spans are written to the agent.

This PR also fixes wildcard rule sampling when multiple * characters are repeated (e.g. ***), which are now considered equivalent to *, meaning "match all".

Motivation:
The ability to sample on tags and resource will be helpful to users trying to reduce costs in a precise way as well as keep those spans that are truly useful to them.

How to test the change?
Added tests for new behaviors and passes system-tests trace_sampling.py

@pr-commenter
Copy link

pr-commenter bot commented Oct 3, 2024

Benchmarks

Benchmark execution time: 2024-10-07 17:50:36

Comparing candidate commit bc81964 in PR branch zachg/lazy_sampling with baseline commit 94cfe27 in branch master.

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

@ZStriker19 ZStriker19 marked this pull request as ready for review October 3, 2024 22:28
@ZStriker19 ZStriker19 requested a review from a team as a code owner October 3, 2024 22:28
@codecov-commenter
Copy link

codecov-commenter commented Oct 3, 2024

Codecov Report

Attention: Patch coverage is 98.43750% with 2 lines in your changes missing coverage. Please review.

Project coverage is 97.85%. Comparing base (56038a3) to head (bc81964).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
lib/datadog/tracing/tracer.rb 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3956      +/-   ##
==========================================
- Coverage   97.86%   97.85%   -0.01%     
==========================================
  Files        1313     1313              
  Lines       78369    78477     +108     
  Branches     3888     3891       +3     
==========================================
+ Hits        76694    76797     +103     
- Misses       1675     1680       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ZStriker19 ZStriker19 changed the title feat: lazy sampling feat: delay sampling decision to allow sampling on tags and resource Oct 7, 2024
Copy link
Member

@marcotc marcotc left a comment

Choose a reason for hiding this comment

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

Awesome work, @ZStriker19!

@marcotc marcotc merged commit 9e26192 into master Oct 7, 2024
248 checks passed
@marcotc marcotc deleted the zachg/lazy_sampling branch October 7, 2024 19:34
@github-actions github-actions bot added this to the 2.4.0 milestone Oct 7, 2024
@y9v y9v mentioned this pull request Oct 11, 2024
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.

3 participants