This repository has been archived by the owner on Oct 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: sampler now samples correctly (#100)
Sampler was not adhering to the configured propability when not ALWAYS or NEVER. Issue was that the Sampler was using Number.MAX_VALUE, which uses 1024-bits. There were two issues with this approach: 1. The MAX_VALUE is NOT considered a "safe integer" and thus there are side effects during manipulation. 2. The `shouldSample` method was only comparing the idUpperBound (based on 1024-bits of data) to the lower 16 characters (64-bits) of a trace, which was resulting in the configured probabilty not being respected. We now us a 52-bit number, which falls within the "safe integer" range (53-bits) and is able to be fully represented by a 13-diget hex value. This allows the value to: 1. Be safely algorithmically manipulated without side effects. 2. Be easily compared to the lower 52-bits (13 characters) of a traceId. The tests have been updated to perform validation of traceIds that should and should not be sampled given a probability.
- Loading branch information
1 parent
ed255e6
commit 7ca6aba
Showing
4 changed files
with
50 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters