litellm/tests/test_litellm/integrations/open_telemetry
ryan-crabbe-berri c754c560dd
fix(proxy): link passthrough success spans to the SERVER root OTEL span (#29315)
* fix(proxy): link passthrough success spans to the SERVER root OTEL span

Passthrough requests never wired user_api_key_dict.parent_otel_span into the
logging metadata, so on success the litellm_request span orphaned into its own
trace and the "Received Proxy Server Request" root span was never ended. Setting
it once in _init_kwargs_for_pass_through_endpoint fixes both the non-streaming
and streaming paths, since update_environment_variables copies that metadata onto
the logging object's model_call_details, which is what the OTEL handler reads.

Resolves LIT-3443

* fix(proxy): set passthrough parent span after client metadata merge

Greptile flagged that litellm_parent_otel_span was assigned before the
_metadata.update() calls that merge request-body metadata, so a client body
mirroring the internal key could overwrite the real span with a JSON scalar
and null the fix for that request. Move the assignment after the merge and
add a regression test that fails on the old ordering.

* fix(proxy): also set user_api_key after client metadata merge

Per Greptile, user_api_key had the same clobber window as the parent span: a
passthrough request body mirroring the key could overwrite the authenticated
value in the logged metadata. Move it into the same post-merge block and add a
deterministic contract test asserting both internal keys resist client-supplied
metadata.
2026-05-29 21:30:45 -07:00
..
data fix(tests): replace deprecated Bedrock Claude 3.7 Sonnet model ID 2026-04-28 14:24:19 -07:00
__init__.py fix(otel): stamp http.response.status_code on all error responses (#28405) 2026-05-23 19:21:32 +00:00
_helpers.py fix(otel): stamp http.response.status_code on all error responses (#28405) 2026-05-23 19:21:32 +00:00
conftest.py fix(otel): stamp http.response.status_code on all error responses (#28405) 2026-05-23 19:21:32 +00:00
test_otel_admin_endpoints.py fix(otel): export SERVER span on management-endpoint success without http_request (#28794) 2026-05-25 12:13:17 -07:00
test_otel_exception_handler.py fix(otel): stamp http.response.status_code on all error responses (#28405) 2026-05-23 19:21:32 +00:00
test_otel_passthrough_endpoints.py fix(otel): stamp http.response.status_code on all error responses (#28405) 2026-05-23 19:21:32 +00:00
test_otel_unified_endpoints.py fix(otel): stamp http.response.status_code on all error responses (#28405) 2026-05-23 19:21:32 +00:00
test_passthrough_parent_span.py fix(proxy): link passthrough success spans to the SERVER root OTEL span (#29315) 2026-05-29 21:30:45 -07:00