Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

Do not apply adaptive sampler to child spans #410

Merged
merged 5 commits into from
Oct 22, 2019

Conversation

yurishkuro
Copy link
Member

@yurishkuro yurishkuro commented Oct 22, 2019

Which problem is this PR solving?

Per-operation adaptive sampling should only apply to service endpoints, not to operation names of the inner/children spans. Recent changes (e.g. #380) broke that functionality and traces can now be sampled by the per-operation sampler triggering on children spans. This is a problem for adaptive sampling backend that only records operations from the root spans, meaning all child operations are getting the default probability, which may be higher than the calculated probabilities.

Short description of the changes

  • Add a test that demonstrates the problem.
  • Change per-operation sampler to only allow sampling "local root spans", which is equivalent to the actual root span of the trace because spans with remote parent are finalized right away.

@codecov
Copy link

codecov bot commented Oct 22, 2019

Codecov Report

Merging #410 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #410      +/-   ##
==========================================
+ Coverage   98.81%   98.81%   +<.01%     
==========================================
  Files          50       50              
  Lines        2023     2027       +4     
  Branches      379      381       +2     
==========================================
+ Hits         1999     2003       +4     
  Misses         24       24
Impacted Files Coverage Δ
src/samplers/per_operation_sampler.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 865ac99...609ec07. Read the comment docs.

Yuri Shkuro added 2 commits October 21, 2019 23:18
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
sp0.setOperationName('op2');
assert.isTrue(sp0.context().isSampled(), 'op2 should be sampled on the root span');

let sp1 = tracer.startSpan('op1', 'op1 should not be sampled');
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we use more descriptive names? parent/child or some such?

return { sample: false, retryable: false, tags: outTags };
}
let isSampled = this.isSampled(span.operationName, outTags);
// returning retryable=true since we can change decision after setOperationName().
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is a bit confusing because we set retryable 'false' onSetOperationName - perhaps "the decision can change the first time setOperationName is called?"

Yuri Shkuro added 2 commits October 22, 2019 13:12
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
@yurishkuro yurishkuro merged commit f94a31d into jaegertracing:master Oct 22, 2019
@yurishkuro yurishkuro deleted the fix-adaptive-sampling branch October 22, 2019 17:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants