-
Notifications
You must be signed in to change notification settings - Fork 410
Be mindful of other logging context filters in 3rd-party code #19068
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
MadLittleMods
merged 8 commits into
develop
from
madlittlemods/no-mangle-log-records-outside-synapse
Oct 31, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
32e7b1e
Be mindful of other logging context filters
MadLittleMods 0256915
Add changelog
MadLittleMods a70a979
Merge branch 'develop' into madlittlemods/no-mangle-log-records-outsi…
MadLittleMods 690e77f
Merge branch 'develop' into madlittlemods/no-mangle-log-records-outsi…
MadLittleMods 2bf0ad7
Fix grammar in docstring
MadLittleMods 0fbd26d
Add 3rd party code example
MadLittleMods 909fcc7
Add clobber keyword
MadLittleMods 3f63149
Merge branch 'develop' into madlittlemods/no-mangle-log-records-outsi…
MadLittleMods 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Be mindful of other logging context filters in 3rd-party code and avoid overwriting log record fields unless we know the log record is relevant to Synapse. |
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.
Is the abstraction worth it? Should I just inline the usage?
Originally, I thought I would have to use it more for all of the request attributes below but turns out we can do a little optimization to avoid it.
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.
Why not move setting the
server_nameunder therequestattribute? Then you'd only have one usage ofsafe_set, and then it'd be even more clear that it's not necessary.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 not following 🙇
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, I meant structuring the code to be be something like the following:
where you get the check for SENTINEL out of the way early, and then run code that assumes a non-sentinel logcontext.
Though, I now realise
safe_setwas checking both that this wasn't the SENTINEL_CONTEXT, as well as checking that the attribute wasn't already set. So the above doesn't completely eliminate the need forsafe_set.Though if
safe_setis now only checking that the attribute is not already set, then it becomes even less necessary, and can probably be removed.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.
nit: I'd also refactor this block like so to save on indentation:
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.
This won't work because not everything is logged with a
context.request(like start-up messages, background jobs, etc)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.
Merged but if we come up with a better pattern, I can make a follow-up PR ⏩
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, I was wondering if there was something like that. Thanks for explaining, looks fine to me then.