litellm/litellm
Yassin Kortam d115edc388
feat(otel): emit the gen_ai.client.operation.exception event on failed LLM calls (#32655)
* feat(otel): emit the gen_ai.client.operation.exception event on failed LLM calls

The GenAI semantic conventions record failures of a GenAI client operation as
a log-based event named gen_ai.client.operation.exception, carrying the
exception.type / exception.message / exception.stacktrace trio at severity
WARN and correlated to the failed span. OTel v2 never emitted it: a failed LLM
call produced only the deprecated error.* span attributes, a generic exception
span event without a stacktrace, and the stacktrace under the vendor key
litellm.provider.error.stack_trace.

Build the logs pipeline (LoggerProvider + console/OTLP log exporters mirroring
the metrics plumbing) and record the event behind the enable_events flag, which
until now was defined but consumed nowhere. An operator-configured LoggerProvider
global is reused so the events ride their existing logs pipeline; an explicit
NoOpLoggerProvider global is honored as an opt-out and builds no recorder at all.

The existing span-side error surface (error.type, error.message, the exception
span event, and the litellm.provider.error.* detail keys) is untouched for
backwards compatibility.

* fix(otel): always ride the semconv-required exception pair on the GenAI event

Filtering the event attributes on truthiness conflated "absent" with "empty",
so an empty exception.type or exception.message would have been dropped, leaving
an event with neither semconv-required field. Build the attributes so the pair is
unconditional and only the recommended stacktrace is omitted when the payload
carries none.

* docs(otel): document the events plumbing module in the package README

* test(otel): cover the log exporter selection and logs endpoint normalization

The new logs plumbing had no coverage for exporter-kind selection, the
console fallback for an unrecognized kind, the /v1/logs signal-path rewriting
that lets one OTEL_ENDPOINT serve every signal, or the simple-vs-batch
processor split.

(cherry picked from commit 99b4c5ed3e)
2026-07-11 13:59:04 -07:00
..
a2a_protocol style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
anthropic_interface style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
assistants style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
batch_completion style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
batches style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
caching style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
completion_extras style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
compression style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
containers style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
endpoints/speech/speech_to_completion_bridge style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
evals style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
experimental_mcp_client style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
files style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
fine_tuning style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
google_genai style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
images style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
integrations feat(otel): emit the gen_ai.client.operation.exception event on failed LLM calls (#32655) 2026-07-11 13:59:04 -07:00
interactions style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
litellm_core_utils fix(bedrock/converse): drop toolSpec.strict for Opus 4.7/4.8 (#31582) (#31923) 2026-07-03 16:43:50 -07:00
llms fix(bedrock): gate in-place system role messages on model support for Claude Invoke (#32831) 2026-07-10 20:38:52 -07:00
models style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
ocr style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
passthrough style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
proxy fix(guardrails): walk Responses-API text taxonomy in shared content helpers (#32542) 2026-07-11 13:58:15 -07:00
proxy_auth style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
rag style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
realtime_api style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
repositories style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
rerank_api style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
responses style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
router_strategy style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
router_utils style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
rust_bridge feat(ocr): thin Rust OCR Python bridge (#31368) 2026-06-25 18:42:59 -07:00
sandbox style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
search style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
secret_managers style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
skills style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
types fix(bedrock): gate in-place system role messages on model support for Claude Invoke (#32831) 2026-07-10 20:38:52 -07:00
vector_store_files style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
vector_stores style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
videos style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
__init__.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
_internal_context.py fix(proxy): harden request parameter handling 2026-04-16 01:38:12 +00:00
_lazy_imports.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
_lazy_imports_registry.py chore: litellm oss staging (#30968) 2026-06-23 07:31:44 -07:00
_logging.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
_redis.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
_redis_credential_provider.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
_service_logger.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
_uuid.py build(deps-dev): bump black to 26.3.1 and apply formatting (#28525) 2026-05-21 17:24:18 -07:00
_version.py
anthropic_beta_headers_config.json chore(oss): litellm oss staging 120626 (#30292) 2026-06-12 09:49:25 -07:00
anthropic_beta_headers_manager.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
blog_posts.json docs(blog): add WebRTC blog post link 2026-03-13 17:54:33 +05:30
budget_manager.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
constants.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
cost.json
cost_calculator.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
exceptions.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
main.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
model_prices_and_context_window_backup.json fix(bedrock): flag mapped Claude 4.8+ entries with supports_mid_conversation_system (#32882) 2026-07-10 22:42:23 -07:00
policy_templates_backup.json feat(add-new-block_code_execution-guardrail): prevent agent from executing code (#22154) 2026-02-25 22:02:14 -08:00
provider_endpoints_support_backup.json chore: litellm oss staging (#30968) 2026-06-23 07:31:44 -07:00
py.typed
router.py fix(router): persist global retry_policy via /config/update (#29540) 2026-06-28 00:20:20 +00:00
scheduler.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
setup_wizard.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
timeout.py style: unify ruff format width on 120 (#31518) 2026-06-27 12:39:29 -07:00
utils.py fix(bedrock): gate in-place system role messages on model support for Claude Invoke (#32831) 2026-07-10 20:38:52 -07:00