Skip to content

add agent id and deployment resource attrs - #6570

Merged
jmcclanahan merged 3 commits into
mainfrom
jakemcclanahan/agent-id-deployment-resource-attrs
Jul 27, 2026
Merged

add agent id and deployment resource attrs#6570
jmcclanahan merged 3 commits into
mainfrom
jakemcclanahan/agent-id-deployment-resource-attrs

Conversation

@jmcclanahan

@jmcclanahan jmcclanahan commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Read LIVEKIT_AGENT_ID and LIVEKIT_AGENT_DEPLOYMENT and include them, as lk.cloud_agent_id / lk.deployment_id, on both the tracing resource and the session metadata (spans + logs) when running on LiveKit Cloud. Follows the existing lk.agent_name pattern; 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 to base_metadata from the env vars.
  • telemetry/trace_types.py: add ATTR_CLOUD_AGENT_ID / ATTR_DEPLOYMENT_ID.

Testing

  • Added tests in tests/test_recording.py (present / unset / empty-deployment).
  • pytest tests/test_recording.py (32 pass) and ruff check pass locally.

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.
@jmcclanahan
jmcclanahan requested a review from a team as a code owner July 27, 2026 19:03
@jmcclanahan jmcclanahan changed the title agent id deployment resource attrs add agent id and deployment resource attrs Jul 27, 2026

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

@jmcclanahan
jmcclanahan merged commit 11989dc into main Jul 27, 2026
26 checks passed
@jmcclanahan
jmcclanahan deleted the jakemcclanahan/agent-id-deployment-resource-attrs branch July 27, 2026 19:42
@jmcclanahan
jmcclanahan restored the jakemcclanahan/agent-id-deployment-resource-attrs branch August 3, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants