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

add experimental priority sampling config as sampling rules #732

Merged
merged 7 commits into from
Nov 6, 2019

Conversation

rochdev
Copy link
Member

@rochdev rochdev commented Oct 31, 2019

What does this PR do?

Add priority sampling configuration as sampling rules.

Motivation

Right now the sample rates are provided by the agent and cannot be configured, which is incompatible with Tracing Without Limits. By adding a configuration, it becomes possible to override the agent and take the sample rate decision in the tracer.

@rochdev rochdev added enhancement New feature or request core labels Oct 31, 2019
@rochdev rochdev added this to the 0.16.0 milestone Oct 31, 2019
@rochdev rochdev requested a review from a team as a code owner October 31, 2019 21:52
@rochdev rochdev changed the title add priority sampling configuration as sampling rules add experimental priority sampling configuration as sampling rules Oct 31, 2019
@rochdev rochdev changed the title add experimental priority sampling configuration as sampling rules add experimental priority sampling config as sampling rules Oct 31, 2019
peers: ['foo'],
sampler: {
sampleRate: 1,
rateLimit: 1000,
Copy link
Member

Choose a reason for hiding this comment

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

🙄

Copy link
Member Author

Choose a reason for hiding this comment

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

😕

@@ -87,6 +98,48 @@ class PrioritySampler {
}
}
}

_isSampledByRule (context, rule) {
const sampled = this._limiter.isAllowed() && rule.sampler.isSampled(context)
Copy link
Member

Choose a reason for hiding this comment

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

this is backwards, we want to only apply the limit on p1 traces

const sampled = this._limiter.isAllowed() && rule.sampler.isSampled(context)

context._metrics[SAMPLING_LIMIT_DECISION] = this._limiter.effectiveRate()
context._metrics[SAMPLING_RULE_DECISION] = rule.sampleRate
Copy link
Member

Choose a reason for hiding this comment

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

we only want to set these if we used that method for sampling.

e.g.

context._metrics[SAMPLING_RULE_DECISION] = rule.sampleRate
if (!rule.sampler.isSampled(context)) return false

const sampled = this._limiter.isAllowed()
context._metrics[SAMPLING_LIMIT_DECISION] = this._limiter.effectiveRate()
return sampled

(ish)

Copy link
Member

Choose a reason for hiding this comment

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

The reason for that is so we can debug why a span was sampled or not. e.g. if we see SAMPLING_RULE_DECISION only, then we can assume it was a p0 because of the rule, not because of rate limiter.

@rochdev rochdev merged commit 084bb02 into master Nov 6, 2019
@rochdev rochdev deleted the priority-sampling-config branch November 6, 2019 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants