-
Notifications
You must be signed in to change notification settings - Fork 153
feat(tracer): add isTraceSampled method #1435
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
Conversation
Hi @icholy thank you for taking the time to open this PR! Please allow us some time to go through the changes and review the PR. |
Co-authored-by: Andrea Amorosi <[email protected]>
Co-authored-by: Andrea Amorosi <[email protected]>
@dreamorosi seems like you have a very specific implementation in mind. I think it would be easier for both of us if you just added your commits on top of mine. |
Hey, sorry, my bad. Should have left a comment instead of getting into the suggestions. I'll delete the suggestion, and please allow me to elaborate why I made them. At the moment, based on the discussion we had some time ago in the linked issue and also the existing implementation, we are relying on the order of the fields inside the environment variable. In the past few weeks, especially after #1356, I think it'd be best to be more defensive when parsing the content of this environment variable and make sure we are not relying on the order of the fields or on the fact that some delimiter are present. Hence my suggestions. My proposal would be to have the In the body of the method, we could make a couple of additional checks while parsing:
This way, the methods consuming the trace data can be more streamlined. |
Your logic makes sense, but personally I think you're giving So parsing
For backwards compatibility, it would place the whole string in the Then the |
You're right, and thanks for hearing me out. Let's go with your proposal, after this I'm looking forward to merge it right away. |
@dreamorosi ready for another review round. |
This comment was marked as resolved.
This comment was marked as resolved.
I think there's one line/code branch not being covered by the tests |
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.
Thank you for contributing the feature and for addressing the comments during the review!
Description of your changes
This change adds a new
isTraceSampled
method toTracer
. It lets users find out if the current trace is sampled or not. This information may be included in structured logs along with the Trace ID.How to verify this change
Set the
Sampled=1
flag in the_X_AMZN_TRACE_ID
environment variable and assert thatisTraceSampled
returnstrue
.Example:
Root=1-5759e988-bd862e3fe1be46a994272793;Parent=557abcec3ee5a047;Sampled=1
Related issues, RFCs
Issue number: #1378
Checklist
Breaking change checklist
Is it a breaking change?: NO
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.