-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a configurable randomness source
I had two goals for this change: 1. Expose the configuration option without exposing any new classes or interfaces. We should be in strict control of possible randomness sources so we can guarantee that they actually do provide random values and that they provide randomness efficiently. I didn't want it to be possible for users to tank performance by inadvertently using a single `Random` instance. 2. Make the random source configurable and scoped to each `AWSXRayRecorder` instance. I didn't want to introduce any more global shared state, so this unfortunately meant I wasn't able to remove the global SecureRandom usage in two places: `TraceId#fromString` and `DefaultThrowableSerializationStrategy#describeInContext`. The latter is at least aware of the current entity and will try to use the ID generator from its creator when possible, but the former is unresolvable without adding more global shared state. This commit adds the following public APIs: * `AWSXRayRecorder#useFastIdGenerator` and `AWSXRayRecorder#useSecureIdGenerator`: for configuring the behavior of each `AWSXRayRecorder` instance. * `AWSXRayRecorderBuilder#useFastIdGenerator` and `AWSXRayRecorderBuilder#useSecureIdGenerator`: same as above * `AWSXRayRecorder#getIdGenerator`: for getting the configured ID generator * `ThrowableSerializationStrategy#describeInContext(Entity, Throwable, List<Subsegment>)`: a new method that allows the current entity to be provided to `ThrowableSerializationStrategy`. This is currently only useful for getting the ID generator from the current entity's creator, but I can imagine there being other uses for this later. There are also some classes under the `internal` package that are `public` by necessity. However, no class outside of `AWSXRayRecorder` has an API dependency on any of them and `AWSXRayRecorder` restricts which implementations can be used, so they're effectively hidden (or non-customizable, anyway). There are some other minor changes in this PR: * Removed quadratic String concatenation when generating Entity IDs * Removed quadratic StringBuilder char insertion when generating Trace IDs * `SegmentContextResolverChain` no longer double-resolves contexts
- Loading branch information
1 parent
878ec87
commit de5aa13
Showing
20 changed files
with
428 additions
and
95 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
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
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
Oops, something went wrong.