Skip to content
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

fix: make SetMetadata add extra labels rather than replace the logger #159

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/isolate/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
# but it handling `source` would be not trivial, so we are better off
# just keeping it simple for now.
class IsolateLogger:
extra_labels: Dict[str, str] = {}

def __init__(self, log_labels: Dict[str, str]):
self.log_labels = log_labels

Expand All @@ -18,6 +20,7 @@ def log(self, level: LogLevel, message: str, source: LogSource) -> None:
"level": level.name,
"message": message,
**self.log_labels,
**self.extra_labels,
}
print(json.dumps(record))

Expand Down
4 changes: 1 addition & 3 deletions src/isolate/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,7 @@ def SetMetadata(

task = self.background_tasks[request.task_id]

task.logger = IsolateLogger.with_env_expanded(
dict(request.metadata.logger_labels)
)
task.logger.extra_labels = dict(request.metadata.logger_labels)

return definitions.SetMetadataResponse()

Expand Down
Loading