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

Fix sampling rate #180

Merged
merged 2 commits into from
Nov 8, 2024
Merged

Fix sampling rate #180

merged 2 commits into from
Nov 8, 2024

Conversation

nhulston
Copy link
Contributor

@nhulston nhulston commented Nov 8, 2024

What does this PR do?

Fixes sampling rates not being respected.

When a sampling priority is set on a span but not in the context, we should still propagate it to the Lambda extension. Previously the sampling priority was not being sent to the extension in this case, causing sampling rates to be incorrect.

Motivation

Sampling rates didn't work before, leading to 100% of traces being sampled regardless of the DD_TRACE_SAMPLING_RULES or DD_TRACE_SAMPLE_RATE environment variables.

Testing Guidelines

Manual testing. Before changes, we saw every trace was being sampled. Now, we see the correct number of traces being sampled depending on the sample rate environment variable.

I also added unit tests in extension_test.go.

Additional Notes

Types of changes

  • Bug fix
  • New feature
  • Breaking change
  • Misc (docs, refactoring, dependency upgrade, etc.)

Checklist

  • This PR's description is comprehensive
  • This PR contains breaking changes that are documented in the description
  • This PR introduces new APIs or parameters that are documented and unlikely to change in the foreseeable future
  • This PR impacts documentation, and it has been updated (or a ticket has been logged)
  • This PR's changes are covered by the automated tests
  • This PR collects user input/sensitive content into Datadog

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.43%. Comparing base (39700b5) to head (4915d91).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #180      +/-   ##
==========================================
+ Coverage   80.55%   81.43%   +0.87%     
==========================================
  Files          13       13              
  Lines         905      937      +32     
==========================================
+ Hits          729      763      +34     
+ Misses        145      142       -3     
- Partials       31       32       +1     

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

@nhulston nhulston marked this pull request as ready for review November 8, 2024 19:48
@nhulston nhulston requested a review from a team as a code owner November 8, 2024 19:48
Copy link
Contributor

@purple4reina purple4reina left a comment

Choose a reason for hiding this comment

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

Great work on this!

@nhulston nhulston merged commit 8ccb084 into main Nov 8, 2024
9 checks passed
@nhulston nhulston deleted the nicholas.hulston/fix-sampling-rate branch November 8, 2024 20:00
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