add agent id and deployment resource attrs - #6570
Merged
jmcclanahan merged 3 commits intoJul 27, 2026
Merged
Conversation
The LiveKit Cloud launcher sets LIVEKIT_AGENT_ID (the cloud agent id) and LIVEKIT_AGENT_DEPLOYMENT (empty for production) as env vars. Merge them into the OTLP tracing resource as lk.cloud_agent_id / lk.deployment_id so Cloud agent insights can attribute conversation telemetry per agent and per deployment without a read-time join. Read the env vars directly here rather than assembling OTEL_RESOURCE_ATTRIBUTES on the pod: Resource.create still merges any customer-set OTEL_RESOURCE_ATTRIBUTES via the standard env detector, so customer attributes are preserved. Empty values (self-hosted, production deployment) are omitted.
…gs too) Follow the agent_name pattern: add the identity attrs to base_metadata so they land on both the tracing resource and the per-span/log session metadata, rather than the resource alone.
chenghao-mou
approved these changes
Jul 27, 2026
jmcclanahan
deleted the
jakemcclanahan/agent-id-deployment-resource-attrs
branch
July 27, 2026 19:42
jmcclanahan
restored the
jakemcclanahan/agent-id-deployment-resource-attrs
branch
August 3, 2026 20:18
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.
Read
LIVEKIT_AGENT_IDandLIVEKIT_AGENT_DEPLOYMENTand include them, aslk.cloud_agent_id/lk.deployment_id, on both the tracing resource and the session metadata (spans + logs) when running on LiveKit Cloud. Follows the existinglk.agent_namepattern; values are omitted when the env vars are unset (e.g. self-hosted, or an empty deployment).Changes
telemetry/traces.py: add the two attributes tobase_metadatafrom the env vars.telemetry/trace_types.py: addATTR_CLOUD_AGENT_ID/ATTR_DEPLOYMENT_ID.Testing
tests/test_recording.py(present / unset / empty-deployment).pytest tests/test_recording.py(32 pass) andruff checkpass locally.