-
Notifications
You must be signed in to change notification settings - Fork 1k
Improve context propagation for brave integration #6139
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
5eafb19
minimal impl
jrhee17 6f5a662
cleanup
jrhee17 f2f0d90
Merge branch 'main' into feat/brave-prop
jrhee17 a525b8a
Merge branch 'main' into feat/brave-prop
jrhee17 23eeedb
add propagation logic to executors
jrhee17 46833c4
address comments by @minwoox and @trustin
jrhee17 933912a
minor nits
jrhee17 f737fea
warn when a different context is set
jrhee17 4598cc8
use object equality for checking trace context equality
jrhee17 2ab56cb
address comment by @minwoox
jrhee17 3296dcb
Merge remote-tracking branch 'origin/main' into feat/brave-prop
jrhee17 835d38d
lint
jrhee17 39ecbe8
Merge branch 'main' into feat/brave-prop
jrhee17 b7dee51
address comment by @ikhoon
jrhee17 fafd081
Merge branch 'main' into feat/brave-prop
jrhee17 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Because a span is fixed to a
RequestContext, how about leaving a warning log if aRequestContexthas aTraceContextalready? I've seen internal customers who have used this API.Also, I think we can remove
@NullablefromsetTraceContextmethod.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.
I'm unsure if leaving a log level with
WARNlevel is a good idea since it is a valid behavior to do so. e.g. UsingTraceContextPropagation#inject(span1) withBraveClient(span2) will also overwrite the span wherespan2.parent == span1.What do you think of leaving a trace level log so that we can guide users if there is unexpected behavior?
Alternatively, I can also add a static field guard so that the log is left only once if you feel strongly of this.
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.
Ah, that's valid situtation. IIUC, in that case, the same
TraceContextcan be set to aRequestContext. Is it right? If so, can't we add a warning log if it tries to set a differentTraceContext?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.
It would help if you could explain why users using this API is a bad idea. If users were setting the
TraceContextmanually before this change, couldn't they continue using it this way after this change as well?Just to be clear are you suggesting that a warning log is printed once guarded by a static variable? or every time a different context is set?
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.
Just to be clear, the following scenario yields different spans:
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.
I've imagined some of this situation. Please let me know if this doesn't make sense:
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.
I still maintain that
Anyways, I've updated to always leave a warning log as you requested. PTAL when you have time
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.
Since it's a valid scenario, could you change to log just one time?
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.
Sorry for chiming in late.
prevTraceContextcould be the server's context where the client is used. The logging could cause confusion despite correct usage.Should we use
ctx.ownAttr(TRACE_CONTEXT_KEY)to check the duplicate context?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.
Good point, done