-
Notifications
You must be signed in to change notification settings - Fork 100
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
Only allocate a new (random) trace ID when trace ID parse fails rathe… #161
Conversation
…r than all the time and prepare for immutable.
By the way, I find the order of methods to look weird when using factories. Filed an issue in aws sdk repo so we can consider the issue consistently aws/aws-sdk-java-v2#1880 |
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.
LGTM, much more readable! Should we make the TraceID
class fully immutable in 3.x
?
@@ -22,54 +22,77 @@ | |||
|
|||
public class TraceID { | |||
|
|||
private static final int TRACE_ID_LENGTH = 35; |
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.
TODO: increase by 1 in ~85 years :D
Also, do you think you could include the benchmarks you're running in the Java SDK benchmark package for future reference? |
Yeah I'm checking them all in, this one happened to be merged last time. |
Yup in 3.x will make this immutable, deprecated the setters in preparation. |
…r than all the time and prepare for immutable.
Noticed that we always allocate a fresh
TraceID
even when parsing one successfully. We should only do so in the case of a failure, since generating a random is very expensive. Most parses are successful. Around 4x speedup.Also cleaned up delimiter parsing using @shengxil's pattern and prepared to make this an immutable class by deprecating setters / constructors and creating factories.
After
Before
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.