feat: add the deployed region to every log record - #6896
Open
theomonnom wants to merge 1 commit into
Open
Conversation
LiveKit Cloud injects LIVEKIT_REGION_NAME into deployed agents (cloud-agents #781). When it is set, tag every log record with a `region` field so logs can be filtered by the region the agent is running in. Nothing is added when the variable is unset (self-hosted, local dev). The env var is inherited by the child processes, so the field is installed on the worker's stdout handler and on the job process' log-forwarding handler, which covers both the worker and the job processes. A logging.Filter is used rather than a log record factory: the factory runs before Logger.makeRecord applies `extra`, so a user (or the worker's own "registered worker" log, which reports the SFU region) passing extra={"region": ...} would raise a KeyError. With a filter, an explicit `region` always wins.
theomonnom
force-pushed
the
theo/log-deployed-region
branch
from
August 18, 2026 22:11
e2d58e6 to
17cb53e
Compare
longcw
approved these changes
Aug 19, 2026
davidzhao
approved these changes
Aug 19, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes AP-1003.
LiveKit Cloud now injects
LIVEKIT_REGION_NAME(the region display name, e.g.ca-central) into deployed agent pods — server side landed in cloud-agents#781.This picks it up in the SDK and tags every log record with a
regionfield:{"message": "registered worker", "level": "INFO", "name": "livekit.agents", "job_id": "...", "region": "ca-central", "timestamp": "..."}