-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[processor/tailsampling] Support hot sampling policy loading #37014
[processor/tailsampling] Support hot sampling policy loading #37014
Conversation
Signed-off-by: Sean Porter <[email protected]>
Will add that changelog entry. |
Signed-off-by: Sean Porter <[email protected]>
initialDecisions := make([]sampling.Decision, lenPolicies) | ||
for i := 0; i < lenPolicies; i++ { | ||
initialDecisions[i] = sampling.Pending | ||
} |
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.
I discovered this little chunk of no-op code, leftover from a decision refactor.
Co-authored-by: Matthew Wear <[email protected]>
Co-authored-by: Matthew Wear <[email protected]>
Signed-off-by: Sean Porter <[email protected]>
@mwear thank you for the review, applied your suggested changes 👍 |
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 code looks good to me. I'll let the codeowners weigh in on the feature addition.
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.
This looks good, thanks! I wonder if you have data about the performance before and after this change.
} | ||
|
||
func (tsp *tailSamplingSpanProcessor) SetSamplingPolicy(cfgs []PolicyCfg) { | ||
tsp.logger.Debug("Setting pending sampling policy", zap.Int("pending.len", len(cfgs))) |
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.
For a follow-up PR: it would be useful to have a counter, stating how many times the sampling policy has been set.
} | ||
tsp.SetSamplingPolicy(cfgs) | ||
|
||
assert.Len(t, tsp.policies, 2) |
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.
this confused me for a little moment, as I was expecting "3" here -- perhaps add another assertion, with Len(t, tsp.pendingPolicy, 3)
, to highlight that the cfgs
has been accepted by SetSamplingPolicy?
I'm merging, the comments I left can be addressed on a follow-up PR. |
…lemetry#37014) #### Description Adding a feature. This pull-request adds support for hot sampling policy loading to the tail sampling processor. This allows the collector (or another service using the processor) to dynamically update tail sampling policy without needing to restart the processor (or the entire collector). This greatly minimizes the impact of sampling policy modifications on pipeline availability and processing. Changes to policy are safely applied on the next tick loop. A collector (and/or other service) could use OpAMP to remotely manage sampling policy with little to no negative impact on pipeline availability and performance. This is what the https://tailctrl.io/ agent did. #### Usage Currently need to define a custom interface in order to set sampling policy. ``` go type SamplingProcessor interface { processor.Traces SetSamplingPolicy(cfgs []tailsamplingprocessor.PolicyCfg) } factory := tailsamplingprocessor.NewFactory() tsp, _ := factory.CreateTraces() sp = tsp.(SamplingProcessor) sp.SetSamplingPolicy(cfgs) ``` #### Testing Added a test to ensure changes to policy are loaded. Using the changes in a private project. --------- Signed-off-by: Sean Porter <[email protected]> Co-authored-by: Matthew Wear <[email protected]>
Description
Adding a feature. This pull-request adds support for hot sampling policy loading to the tail sampling processor. This allows the collector (or another service using the processor) to dynamically update tail sampling policy without needing to restart the processor (or the entire collector). This greatly minimizes the impact of sampling policy modifications on pipeline availability and processing. Changes to policy are safely applied on the next tick loop.
A collector (and/or other service) could use OpAMP to remotely manage sampling policy with little to no negative impact on pipeline availability and performance. This is what the https://tailctrl.io/ agent did.
Usage
Currently need to define a custom interface in order to set sampling policy.
Testing
Added a test to ensure changes to policy are loaded. Using the changes in a private project.