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

Use incoming sample priority to decide if the span should be sampled or not #521

Merged
merged 6 commits into from
Aug 23, 2018

Conversation

pawelchcki
Copy link
Contributor

@pawelchcki pawelchcki commented Aug 23, 2018

If sampling_priority was set on context from incoming headers or manually by the user. That value then got ignored and overwritten by PrioritySampler.

This PR fixes this issue.

TODO:

  • add tests

@pawelchcki pawelchcki changed the title Stop ignoring incoming sample priority Use incoming sample priority to decide if the span should be sampled or not Aug 23, 2018
@pawelchcki pawelchcki requested a review from delner August 23, 2018 18:08
@pawelchcki pawelchcki self-assigned this Aug 23, 2018
@pawelchcki pawelchcki added bug Involves a bug core Involves Datadog core libraries labels Aug 23, 2018
delner
delner previously approved these changes Aug 23, 2018
Copy link
Contributor

@delner delner left a comment

Choose a reason for hiding this comment

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

Seems fine, just one comment regarding how the test is written. Would recommend rewriting it as RSpec, but its a non-blocker.

tracer.provider.context.sampling_priority = Datadog::Ext::Priority::USER_REJECT
tracer.trace('test_reject', trace_id: 4) {}

assert_equal(2, tracer.writer.spans.length)
Copy link
Contributor

Choose a reason for hiding this comment

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

For brevity, this is okay right now, but when this gets refactored into RSpec, we should assert each one did as expected. Otherwise this test could pass if it were doing the complete opposite that we want, because there would still be two spans.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. I've just added a test te verify all spans are named 'test_keep'.

Also this would have probably been nicer to write in RSpec. I chose to keep minitest only to shorten the dev-time.

@pawelchcki
Copy link
Contributor Author

Thanks for reviewing! @delner I've added a test to verify only the spans we want are kept.

Can you rereview ? 😄

@delner delner added this to the 0.14.2 milestone Aug 23, 2018
Copy link
Contributor

@delner delner left a comment

Choose a reason for hiding this comment

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

👍

@pawelchcki pawelchcki merged commit 5bc8564 into master Aug 23, 2018
@pawelchcki pawelchcki deleted the fix/distributed_sampling branch August 23, 2018 18:52
@pawelchcki pawelchcki restored the fix/distributed_sampling branch August 23, 2018 19:42
@delner delner deleted the fix/distributed_sampling branch September 10, 2018 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Involves a bug core Involves Datadog core libraries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants