Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Anthropic metadata routes remain unstamped, and the new test violates enforced test-placement and LIT010 rules
5 open findings
What changed in this PR
Moves proxy-root team attribute stamping before span closure to prevent ended-span warnings
Changes:
- Reorders team attribute stamping on successful requests
- Adds an in-memory OpenTelemetry regression test
| File | Description |
|---|---|
litellm/integrations/opentelemetry.py |
Stamps team attributes before closing the proxy span |
tests/unit/integrations/test_otel_proxy_span_lifecycle.py |
Tests successful proxy span closure and attributes |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Set the team id and alias attributes on the proxy request span before the span ends, reading them from either litellm_metadata or metadata, so they are exported instead of being dropped with an 'attribute on ended span' warning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a954c96 to
433cb5a
Compare
|
CI note: the Rebased onto current |


What does this change?
Stamp proxy-root team attributes before the success callback closes the
LiteLLM-created proxy span. The same lookup now covers metadata used by
Anthropic routes.
Why?
_handle_successcurrently calls_close_proxy_span_ok, which ends the proxyroot, and then calls
_set_team_attributes_on_proxy_span_from_kwargs. Thesecond call attempts to set attributes on the ended span and OpenTelemetry
emits
Setting attribute on ended span.. This was reproduced against thepinned gateway and the current upstream head.
Testing
tests/unit/integrations/test_opentelemetry.pywith an in-memorytracer regression covering both metadata containers, finished root
attributes, and zero ended-span warnings
python3 -m py_compile litellm/integrations/opentelemetry.py tests/unit/integrations/test_opentelemetry.pywith no provider credentials or OTLP exporter
not installed; hosted unit and lint checks are running on this PR
Related context: #16779