-
Notifications
You must be signed in to change notification settings - Fork 392
Provide a default value for server_name
to LoggingContext
#19003
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix `server_name` in logging context for multiple Synapse instances in one process. |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -285,7 +285,11 @@ class LoggingContext: | |||||||||||||
Args: | ||||||||||||||
name: Name for the context for logging. | ||||||||||||||
server_name: The name of the server this context is associated with | ||||||||||||||
(`config.server.server_name` or `hs.hostname`) | ||||||||||||||
(`config.server.server_name` or `hs.hostname`). | ||||||||||||||
|
||||||||||||||
If not provided, this will be set to "SERVER_NAME_NOT_PROVIDED". | ||||||||||||||
This is a backwards-compatibility patch for | ||||||||||||||
https://github.com/matrix-org/synapse-s3-storage-provider/issues/133. | ||||||||||||||
parent_context (LoggingContext|None): The parent of the new context | ||||||||||||||
request: Synapse Request Context object. Useful to associate all the logs | ||||||||||||||
happening to a given request. | ||||||||||||||
|
@@ -309,7 +313,7 @@ def __init__( | |||||||||||||
self, | ||||||||||||||
*, | ||||||||||||||
name: str, | ||||||||||||||
server_name: str, | ||||||||||||||
server_name: str = "SERVER_NAME_NOT_PROVIDED", | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
To better match what we have in the codebase:
We could go even further if we add a lint to enforce
Suggested change
This matches the existing
Suggested change
We can align on whatever pattern we think is best. |
||||||||||||||
parent_context: "Optional[LoggingContext]" = None, | ||||||||||||||
request: Optional[ContextRequest] = None, | ||||||||||||||
) -> None: | ||||||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.
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.
While, I didn't forsee this problem when making the change, setting a default encourages people not to set this appropriately even in our own Synapse codebase. We could add a lint for our own codebase 🤔
Should downstream consumers really be using
LoggingContext
? Probably notThis basically the same reasoning I used in #18989 (comment)
I would much rather push harder down this route if we're willing (which means this PR isn't necessary).