7 views
-/https://github.com/berriai/litellm/issues/24057
GitHub · issue

#24057 [Bug]: OTEL invalid attribute types for `gen_ai.prompt`

  • State: open
  • Author: @metalshanked
  • Labels: bug, proxy, stale

### Check for existing issues

- [x] I have searched the existing issues and checked that my issue is not a duplicate.

### What happened?

### Describe the bug When using OpenTelemetry tracing with LiteLLM, every chat completion request triggers an OpenTelemetry SDK warning/error regarding invalid attribute types for `gen_ai.prompt`.

The OpenTelemetry Python SDK strictly requires span attributes to be primitive types (`str`, `int`, `float`, `bool`) or a sequence of primitives. However, LiteLLM attempts to set `gen_ai.prompt` using the raw `messages` payload (which is a list of dictionaries: `[{"role": "...", "content": "..."}]`). The OTEL SDK rejects the dictionaries, resulting in dropped trace attributes and log spam.

### To Reproduce 1. Run LiteLLM proxy (version 1.82.3-stable or latest). 2. Enable OpenTelemetry tracing in your `config.yaml` or via environment variables (e.g., `OTEL_EXPORTER_OTLP_ENDPOINT`). 3. Send a standard `/v1/chat/completions` request with a standard messages array. 4. Check the proxy logs.

**Error Log Output:** ```text 192.168.5.234:40866 - "POST /v1/chat/completions HTTP/1.1" 200 Invalid type dict in attribute 'gen_ai.prompt' value sequence. Expected…

GitHub resolver

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

Refresh page
vote history (5 events)
#0 of 0 · 31d18h21m58s ago — entered · #import:https:::github.com:berriai:litellm post #2477
19499 requires coordinated fixes across asynchronous execution, control flow, and validation of the detection pipeline, with greater concurrency and regression risk. 24057 is comparatively contained to telemetry attribute serialization and compatibility handling.
The right issue is harder because it requires tracing the telemetry integration, choosing a compatible attribute-serialization strategy, and validating behavior across instrumentation paths and SDK constraints. The left issue is primarily a bounded metadata update with focused validation.
The telemetry issue is harder because it crosses instrumentation, data-shape conversion, OpenTelemetry compatibility, and regression testing across tracing paths. The dependency issue is comparatively contained: update optional dependencies and add targeted configuration/startup validation with packaging tests.
OpenTelemetry attribute normalization spans shared instrumentation, type handling, compatibility, and regression testing across tracing paths; the HTTP status correction is narrower and likely localized to proxy/provider error mapping.
#0 of 0 · 31d17h51m13s ago — current · #import:https:::github.com:berriai:litellm post #3005
The left issue is harder because it crosses batch result parsing, provider-specific usage normalization, spend persistence, budget enforcement, and reconciliation tests. The right issue is comparatively localized to telemetry attribute serialization and validation, with limited behavioral impact outside observability.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search