Support delayed sampling#380
Support delayed sampling#380yurishkuro merged 28 commits intojaegertracing:masterfrom yurishkuro:delayed-sampling
Conversation
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
| assert.equal(prevTagLength, span._tags.length, 'The sampling.priority tag should only be set once'); | ||
| }); | ||
|
|
||
| describe('adaptive sampling tests for span', () => { |
There was a problem hiding this comment.
moved to top level test below
| _samplingRate: number; | ||
|
|
||
| constructor(samplingRate: number) { | ||
| super('ProbabilisticSampler'); |
There was a problem hiding this comment.
Is calling by name the preferred way of invoking super? It seems pretty fragile
There was a problem hiding this comment.
it simply passes the "name" that is used in toString and uniqueName() functions.
| } | ||
|
|
||
| update(samplingRate: number): boolean { | ||
| if (this._samplingRate == samplingRate) { |
There was a problem hiding this comment.
Is there an equality function which takes in an epsilon for float comparisons?
There was a problem hiding this comment.
not that I know off. I don't think it matters here. If the rate is coming from JSON strategy, then float representation will be the same as long as the string representation is the same.
| _baggage: any; | ||
| _debugId: ?string; | ||
| _samplingState: SamplingState; | ||
| _remote: boolean; // indicates that span context represents a remote parent |
There was a problem hiding this comment.
Replace with isRemoteParent?
There was a problem hiding this comment.
In Java Beans naming we don't add is to the field names. And parent would be incorrect here because it's this span context that is "remote".
| } | ||
|
|
||
| declare type PrioritySamplerState = { | ||
| samplerFired: Array<boolean>, |
There was a problem hiding this comment.
How is samplerFired different than retryable?
There was a problem hiding this comment.
samplerFired is set once the given sampler returns retryabe=false. I will add a type comment.
| assert.isFalse(span._spanContext.samplingFinalized, 'finalized'); | ||
| }); | ||
|
|
||
| it('should sample and finalize created span with tag', () => { |
There was a problem hiding this comment.
Might be better to nest these under a "matching tag(s)" describe block
|
I think the API looks pretty usable |
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
| this._sampler = new PrioritySampler([tagSampler, this._sampler]); | ||
| return true; | ||
| } | ||
| return super._updateSampler(strategy); |
There was a problem hiding this comment.
@vprithvi this is working, but is hacky, because super._updateSampler works in-place, so I have to do tricks with overriding this._sampler multiple times. Also, the tag & priority samplers are replaced every time, which is not necessarily a problem since they are both stateless and we don't run updates frequently.
There was a problem hiding this comment.
These trade offs seem reasonable for our use case
|
|
||
| it('should parse extended strategy response', function(done) { | ||
| server.addStrategy('service1', { | ||
| strategyType: 'extended', |
There was a problem hiding this comment.
Not a fan of this in the short term bc it would mean that the backend implementation would need to modify the payload from the thrift sampling object (or modify it after it has been converted to JSON).
There was a problem hiding this comment.
The easiest way to avoid it is to nest the "classic" response under a property.
| remoteSampler.close(); | ||
| }); | ||
|
|
||
| it('should parse extended strategy response', function(done) { |
There was a problem hiding this comment.
as a POC this works, but we probably need to add more tests to ensure that the extended remote sampler can switch back and forth between extended and normal adaptive behavior.
Signed-off-by: Yuri Shkuro <[email protected]>
| this._sampler = new PrioritySampler([tagSampler, this._sampler]); | ||
| return true; | ||
| } | ||
| return super._updateSampler(strategy); |
There was a problem hiding this comment.
These trade offs seem reasonable for our use case
|
|
||
| it('should parse extended strategy response', function(done) { | ||
| server.addStrategy('service1', { | ||
| strategyType: 'extended', |
There was a problem hiding this comment.
Not a fan of this in the short term bc it would mean that the backend implementation would need to modify the payload from the thrift sampling object (or modify it after it has been converted to JSON).
Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: Yuri Shkuro <[email protected]>
Which problem is this PR solving?
Short description of the changes
finalizedmode is no longer early triggered by read operations like injecting context or starting a child span. Instead, sampling may remain unfinalized indefinitely if at least one of the samplers returnsretryable=true.remoteflag in SpanContext that is set when the context has been extracted from a carrier/request. When a child span has a remote context as a parent, the child sampling is finalized immediately, thus preserving the existing behavior of respecting the upstream sampling decision.retryable=falsefromonCreateSpan. If someone wants a deferred sampling behavior, then some samplers should be returningretryable=true.