Skip to content

[Bug]: Potential runtime panic in adaptive sampling addJitter function #8149

@krsatyamthakur-droid

Description

@krsatyamthakur-droid

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

Deployment configs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions