6 views
-/https://github.com/berriai/litellm/issues/33511
GitHub · issue

#33511 [Bug]: raw_gen_ai_request is started after its litellm_request parent has ended

  • State: open
  • Author: @hassiebp

## Description

The OpenTelemetry integration creates `raw_gen_ai_request` after its `litellm_request` parent has already ended.

The exported timestamps and parent ID look correctly nested because both spans are created with explicit historical `start_time` / `end_time` values. However, the actual processor lifecycle is:

1. `litellm_request.on_start` 2. `litellm_request.on_end` 3. `raw_gen_ai_request.on_start` 4. `raw_gen_ai_request.on_end`

Relevant code:

- `_start_primary_span()` ends `litellm_request` before returning it: https://github.com/BerriAI/litellm/blob/main/litellm/integrations/opentelemetry.py#L1229-L1234 - `_maybe_log_raw_request()` subsequently uses that ended span as the parent: https://github.com/BerriAI/litellm/blob/main/litellm/integrations/opentelemetry.py#L1253-L1262

This causes processors that track active parents to treat `raw_gen_ai_request` as a new root. For example, Langfuse marks these raw spans as application roots even though their persisted parent is `litellm_request`.

Observed with Google ADK using the LiteLLM SDK with a `litellm_proxy/...` model.

## Expected lifecycle

```text litellm_request.on_start raw_gen_ai_request.on_start raw_gen_ai…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (7 events)
#0 of 0 · 31d19h1m36s ago — entered · #import:https:::github.com:berriai:litellm post #1853
The right issue is harder because it requires propagating deployment-resolution metadata through router, proxy response, header, streaming, and compatibility paths, with broader API and regression-test impact. The left issue is more concentrated in tracing span ordering and processor lifecycle handling, though it carries integration-specific correctness risk.
The left issue is harder because it crosses proxy callback handling, browser security behavior, OAuth compatibility, and client-specific URI schemes, requiring end-to-end validation. The right issue is narrower in scope, centered on correcting span lifecycle ordering and associated instrumentation tests, though it carries observability compatibility risk.
The right issue is harder because it requires correcting span lifecycle semantics while preserving parentage, processor behavior, and compatibility across telemetry integrations, with subtle regression risk. The left issue is comparatively contained to aligning an existing UI endpoint with the shared health-status data source.
The right issue is harder because it requires careful changes to asynchronous observability lifecycle semantics, parent-child span handling, compatibility across exporters, and regression coverage. The left issue appears more localized to proxy team lookup or upgrade/migration behavior, with a narrower implementation surface.
The right issue requires coordinated changes to tracing lifecycle behavior, parent-child span handling, and regression coverage across integrations. The left issue provides no actionable technical scope, so its implementation effort is substantially lower or indeterminate.
Issue 29274 is harder because it requires reconciling multiple model-discovery sources, defining consistent provider semantics, and preserving SDK compatibility across a broad registry surface. Issue 33511 is narrower, focused on correcting span ordering and validating telemetry behavior.
#0 of 0 · 31d17h47m28s ago — current · #import:https:::github.com:berriai:litellm post #3097
WaveSpeed requires a new provider spanning multiple API modalities, asynchronous workflows, authentication, model routing, and broad testing, while the telemetry issue is comparatively localized to span lifecycle ordering and regression coverage.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search