Skip to content

[Single Span Sampling] Add single span sampling rule#2091

Merged
marcotc merged 36 commits into
feature-single-span-samplingfrom
single-span-rule
Jun 30, 2022
Merged

[Single Span Sampling] Add single span sampling rule#2091
marcotc merged 36 commits into
feature-single-span-samplingfrom
single-span-rule

Conversation

@marcotc

@marcotc marcotc commented Jun 16, 2022

Copy link
Copy Markdown
Member

Follow up to #2055

This PR adds a sampling rule that applies a sampling rate (between 0% and 100% sampling) to a single span operation.

This rate is only applied if the provided matcher, introduced in #2055, is satisfied.

Additionally, a rate limiter (spans/sec limit) is applied to spans that satisfy both the matcher and sampling rate.

If the span is kept after all these checks, a few metrics are set in the span to let the Datadog App downstream know how the sampling happened: this allows it to adjust rates reported in the App despite receiving only a subset of the spans. It also allows users to know how much rate limiting is affecting their observability.

Also a reminder that the concept of "Single Span Sampling" only applies to spans that are part of traces that were dropped at trace-level sampling. Spans that are part of traces that have been successfully sampled do not need Single Span Sampling to be ingested.

@marcotc marcotc added the feature Involves a product feature label Jun 16, 2022
@marcotc
marcotc requested a review from a team June 16, 2022 22:19
@marcotc marcotc self-assigned this Jun 16, 2022
@marcotc
marcotc force-pushed the single-span-rule branch from b605277 to 61c7e02 Compare June 17, 2022 16:31
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

Merging #2091 (61c7e02) into master (cd8dc6d) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #2091      +/-   ##
==========================================
- Coverage   97.49%   97.49%   -0.01%     
==========================================
  Files        1031     1034       +3     
  Lines       53216    53288      +72     
==========================================
+ Hits        51882    51952      +70     
- Misses       1334     1336       +2     
Impacted Files Coverage Δ
lib/datadog/tracing/sampling/span/ext.rb 100.00% <100.00%> (ø)
lib/datadog/tracing/sampling/span/rule.rb 100.00% <100.00%> (ø)
spec/datadog/tracing/sampling/span/rule_spec.rb 100.00% <100.00%> (ø)
lib/datadog/core/diagnostics/environment_logger.rb 98.41% <0.00%> (-1.59%) ⬇️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

marcotc and others added 6 commits June 17, 2022 15:26
* Add host information utility

* fixup! Add host information utility

* Rename file to platform

* fixup! Rename file to platform

* Require etc in file
* CI: Increase build and test jobs to medium+

* Reduce to small for small jobs
@marcotc
marcotc changed the base branch from master to feature-single-span-sampling June 23, 2022 20:07
TonyCTHsu and others added 10 commits June 24, 2022 14:01
I'd like to thank @marcotc for adding the issue templates in #2090!

Here's a few more tweaks inspired from the
[issue templates](https://github.com/DataDog/libdatadog/tree/main/.github/ISSUE_TEMPLATE)
we have for `libdatadog`.

For the bug report template:

* Mention log messages and screenshots in "steps to reproduce"
  suggestions
* Add a "How does ddtrace help you" section. This helps us to know
  more about the customer's use case, and also gives some space
  for customers to hopefully tell us what we're doing well

For the feature request template:

* Add a few sections to guide the feature request.
Inspired by #2090 where we added templates for issues, I've decided
to add a pull request template as well.

I took this from
<https://github.com/DataDog/libdatadog/tree/main/.github/ISSUE_TEMPLATE>
where it has been serving us well, and all feedback is welcome :)
This PR fixes the YARD documentation return type of `c.tracing.partial_flush.min_spans_threshold`.
Adds a link to https://github.com/DataDog/dd-trace-rb/blob/master/docs/DevelopmentGuide.md to the PR template, to help developers test and clean up their code.

Also, expand the language around testing requirements for the PR

@ivoanjo ivoanjo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Left a few minor notes, but overall LGTM 👍

Comment thread lib/datadog/tracing/sampling/span/ext.rb Outdated
Comment on lines +32 to +33
@sampler = Sampling::RateSampler.new
@sampler.sample_rate = sample_rate

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this can be simplified as

Suggested change
@sampler = Sampling::RateSampler.new
@sampler.sample_rate = sample_rate
@sampler = Sampling::RateSampler.new(sample_rate)

...or am I missing something? 🤔

@marcotc marcotc Jun 28, 2022

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I added a comment explaining: it's an annoyance with how RateSampler validates initializer parameters.
Changing it would be a breaking change, so I added a note for a change for v2.0.

Comment thread lib/datadog/tracing/sampling/span/rule.rb
@marcotc
marcotc merged commit 4f3c210 into feature-single-span-sampling Jun 30, 2022
@marcotc
marcotc deleted the single-span-rule branch June 30, 2022 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Involves a product feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants