-
Notifications
You must be signed in to change notification settings - Fork 131
Conversation
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
a40a9f9
to
d077561
Compare
@@ -244,166 +252,180 @@ describe('span should', () => { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to top level test below
_samplingRate: number; | ||
|
||
constructor(samplingRate: number) { | ||
super('ProbabilisticSampler'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is calling by name the preferred way of invoking super? It seems pretty fragile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it simply passes the "name" that is used in toString and uniqueName() functions.
@@ -26,6 +28,14 @@ export default class ProbabilisticSampler implements LegacySamplerV1 { | |||
this._samplingRate = samplingRate; | |||
} | |||
|
|||
update(samplingRate: number): boolean { | |||
if (this._samplingRate == samplingRate) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an equality function which takes in an epsilon for float comparisons?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
@@ -26,6 +26,7 @@ export default class SpanContext { | |||
_baggage: any; | |||
_debugId: ?string; | |||
_samplingState: SamplingState; | |||
_remote: boolean; // indicates that span context represents a remote parent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace with isRemoteParent
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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".
test/samplers/delayed_sampling.js
Outdated
} | ||
|
||
declare type PrioritySamplerState = { | ||
samplerFired: Array<boolean>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is samplerFired
different than retryable
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
samplerFired is set once the given sampler returns retryabe=false. I will add a type comment.
test/samplers/delayed_sampling.js
Outdated
assert.isFalse(span._spanContext.samplingFinalized, 'finalized'); | ||
}); | ||
|
||
it('should sample and finalize created span with tag', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
this._sampler = new PrioritySampler([tagSampler, this._sampler]); | ||
return true; | ||
} | ||
return super._updateSampler(strategy); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vprithvi thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The easiest way to avoid it is to nest the "classic" response under a property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just made that change
remoteSampler.close(); | ||
}); | ||
|
||
it('should parse extended strategy response', function(done) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <ys@uber.com>
this._sampler = new PrioritySampler([tagSampler, this._sampler]); | ||
return true; | ||
} | ||
return super._updateSampler(strategy); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <ys@uber.com>
Signed-off-by: Yuri Shkuro <ys@uber.com>
Which problem is this PR solving?
Short description of the changes
finalized
mode 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
.remote
flag 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=false
fromonCreateSpan
. If someone wants a deferred sampling behavior, then some samplers should be returningretryable=true
.