-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[Bug]: Potential runtime panic in adaptive sampling addJitter function #8149
Description
What happened?
A potential runtime panic exists in the addJitter function used by the adaptive sampling processor. The function calculates jitter by calling rand.Int63n(int64(jitterAmount/2)). If the input jitterAmount is 0 or 1ns, the integer division jitterAmount/2 results in 0. Passing 0 to rand.Int63n results in a runtime panic: panic: invalid argument to Int63n. While these durations are typically configured in seconds, the lack of validation in Options
means a misconfiguration (e.g., in a test environment or yaml typo) can crash the collector.
Steps to reproduce
1.Initialize an adaptive sampling PostAggregator or Provider with a FollowerLeaseRefreshInterval of 0 or 1ns.
2.Wait for the calculation loop to hit the addJitter call.
3.The process will crash with panic: invalid argument to Int63n.
Expected behavior
The function should handle small durations gracefully (e.g., by returning the duration without jitter) or the Options
should be validated to ensure a minimum safe duration.
Proposed Fix Add a guard check to ensure the argument to Int63n is positive:
Relevant log output
Screenshot
No response
Additional context
No response
Jaeger backend version
No response
SDK
No response
Pipeline
No response
Stogage backend
No response
Operating system
No response
Deployment model
No response