litellm/litellm/integrations
ryan-crabbe-berri 886e91b85e
fix(otel): stamp http.response.status_code on all error responses (#28405)
* fix(otel): stamp http.response.status_code on all error responses

httpx.HTTPStatusError exposes status under .response.status_code, not as a
top-level attr, so unified-endpoint 5xx failures left the SERVER span without
a status. The admin hooks only wrote a child span and never stamped or ended
the parent at all, so admin 4xx/5xx (and success) responses were invisible
to dashboards. Adds a fallback to .response.status_code in get_error_information,
and ends the parent SERVER span in async_management_endpoint_{success,failure}_hook
with the same _record_exception_on_span helper the unified path uses.

Resolves LIT-3193

* test(otel): exercise httpx.HTTPStatusError through admin path

Pins the contract that get_error_information's response.status_code fallback
is reachable from any entry point — without this, a future refactor that
bypasses _record_exception_on_span in the admin hooks could regress for
httpx-wrapped exceptions while the unified suite still passes.

* chore(otel): trim verbose comments in LIT-3193 changes

Tighten docstrings and remove redundant section dividers/inline narration.
Behavior is unchanged.

* fix(otel): set span.status on management hook parent SERVER span

Mirror the unified failure path: stamp StatusCode.ERROR on the parent
SERVER span before recording the exception, and StatusCode.OK before
ending it on success. Without this, OTEL backends filtering on span
status (the idiomatic primitive) miss admin-endpoint failures even
though the http.response.status_code attribute is correct.

Extend assert_server_span_attrs to assert span.status.status_code
matches the expected outcome so the gap can't regress.

* fix(otel): close SERVER span on body-validation and unhandled errors

Stash the SERVER span on request.state in auth so FastAPI exception
handlers can finish it for failures that occur after auth but before
the route handler (e.g. /model/new TypeError, /key/generate
RequestValidationError). Without this, those requests left dangling
spans missing http.response.status_code.

Resolves LIT-3193

* fix(otel): generic 500 body, log exception details server-side

Don't leak str(exc) and type(exc).__name__ to clients on uncaught
exceptions. The full traceback is logged via verbose_proxy_logger and
the SERVER span still gets http.response.status_code=500.

Resolves LIT-3193

* fix(otel): stamp http.response.status_code on every SERVER span path

Closes three remaining gaps where the proxy SERVER span ended without
the http.response.status_code attribute:

1. ProxyException raised from _read_request_body (e.g. invalid JSON
   body) bubbled out of user_api_key_auth before the SERVER span was
   created, so the FastAPI handler had nothing to close and the trace
   never reached the backend. Hoist the span creation to a new
   idempotent _ensure_parent_otel_span_on_request_state helper called
   at the top of user_api_key_auth; wire openai_exception_handler to
   close the dangling span. Covers /v1/chat/completions, /v1/messages,
   /v1/responses (shared handler).

2. /v1/responses success — _handle_success ends the proxy span before
   async_post_call_success_hook fires on this path, so the hook's
   set_response_status_code_attribute(200) silently no-op'd against an
   ended span. Stamp 200 + set OK status at the close site in
   _handle_success / _end_proxy_span_from_kwargs via a shared
   _close_proxy_span_ok helper, so the attribute lands regardless of
   which success hook runs first.

3. Failure path for exceptions without code/status_code (e.g. a bare
   TypeError surfacing through _handle_llm_api_exception) — empty
   error_information.error_code → _record_exception_on_span skips the
   stamp → the hook ends the span. Default to 500 in
   async_post_call_failure_hook so the attribute is always set.

Resolves LIT-3193
2026-05-23 19:21:32 +00:00
..
_types style: run black formatter on entire codebase 2026-03-11 17:07:57 -03:00
agentops style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
arize fix(security): sandbox jinja2 in gitlab/arize/bitbucket prompt managers 2026-05-02 09:14:02 +00:00
azure_sentinel Add Azure Sentinel audit log support (#27280) 2026-05-06 15:50:06 -07:00
azure_storage style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
bitbucket fix(security): sandbox jinja2 in gitlab/arize/bitbucket prompt managers 2026-05-02 09:14:02 +00:00
cloudzero style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
compression_interception Prompt Compression - add it to the proxy (#25729) 2026-04-20 15:08:00 -07:00
datadog style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
deepeval fix: use fastuuid helper (#14903) 2025-09-25 15:47:01 -07:00
dotprompt fix(proxy): improve input validation on management endpoints 2026-04-09 14:14:53 -07:00
email_templates style: run black formatter on entire codebase 2026-03-11 17:07:57 -03:00
focus build(deps-dev): bump black to 26.3.1 and apply formatting (#28525) 2026-05-21 17:24:18 -07:00
gcs_bucket fix cloud storage file guards 2026-05-01 15:34:11 -07:00
gcs_pubsub Fix gcs pub sub logging with env var GCS_PROJECT_ID (#10042) 2025-04-15 21:50:48 -07:00
generic_api feat(logging): add retry settings for generic API logger (#26645) 2026-04-28 08:38:17 -07:00
generic_prompt_management style: run black formatter on entire codebase 2026-03-11 17:07:57 -03:00
gitlab fix(security): sandbox jinja2 in gitlab/arize/bitbucket prompt managers 2026-05-02 09:14:02 +00:00
langfuse fix(callbacks): preserve langfuse secret alias 2026-04-30 14:36:51 -07:00
levo docs: remove docs/my-website, point contributors to litellm-docs 2026-04-24 14:17:46 -07:00
litellm_agent Agent Builder - support new experimental agent builder, to ensure agents pass compliance checks (#21817) 2026-02-21 15:32:47 -08:00
opentelemetry_utils feat: add OTEL GenAI latest-experimental semantic convention support (#27418) 2026-05-15 17:20:04 -07:00
opik build(deps-dev): bump black to 26.3.1 and apply formatting (#28525) 2026-05-21 17:24:18 -07:00
prometheus_helpers perf: cap Prometheus end-user metric cardinality with TTL + LRU eviction (#27272) 2026-05-06 13:35:13 -07:00
SlackAlerting build(deps-dev): bump black to 26.3.1 and apply formatting (#28525) 2026-05-21 17:24:18 -07:00
vantage style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
vector_store_integrations style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
weave style: run black formatter on entire codebase 2026-03-11 17:07:57 -03:00
websearch_interception Emit native web_search_tool_result blocks for Anthropic clients (Claude Desktop / Cowork citations) (#27886) 2026-05-14 12:30:47 -07:00
__init__.py add linting 2023-08-18 11:05:05 -07:00
additional_logging_utils.py build(deps-dev): bump black to 26.3.1 and apply formatting (#28525) 2026-05-21 17:24:18 -07:00
anthropic_cache_control_hook.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
argilla.py build(pyproject.toml): add new dev dependencies - for type checking (#9631) 2025-03-29 11:02:13 -07:00
athina.py build(pyproject.toml): add new dev dependencies - for type checking (#9631) 2025-03-29 11:02:13 -07:00
braintrust_logging.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
braintrust_mock_client.py style: run black formatter on entire codebase 2026-03-11 17:07:57 -03:00
callback_configs.json feat: ability to trace metrics 2026-02-25 22:03:51 +05:30
custom_batch_logger.py build(deps-dev): bump black to 26.3.1 and apply formatting (#28525) 2026-05-21 17:24:18 -07:00
custom_guardrail.py Litellm oss staging (#28161) 2026-05-18 16:27:44 -07:00
custom_logger.py Emit native web_search_tool_result blocks for Anthropic clients (Claude Desktop / Cowork citations) (#27886) 2026-05-14 12:30:47 -07:00
custom_prompt_management.py [Fix] CI/CD - mypy & check_code_and_doc_quality & mcp_testing (#17920) 2025-12-13 08:18:43 -08:00
custom_secret_manager.py style: run black formatter on entire codebase 2026-03-11 17:07:57 -03:00
custom_sso_handler.py chore(auth): require trusted proxy for header identity auth 2026-04-29 21:20:21 -07:00
dynamodb.py fix: use fastuuid helper (#14903) 2025-09-25 15:47:01 -07:00
email_alerting.py (code quality) run ruff rule to ban unused imports (#7313) 2024-12-19 12:33:42 -08:00
galileo.py (code quality) run ruff rule to ban unused imports (#7313) 2024-12-19 12:33:42 -08:00
greenscale.py LITELLM: Remove requests library usage (#7235) 2024-12-17 12:50:04 -08:00
helicone.py style: run black formatter on entire codebase 2026-03-11 17:07:57 -03:00
helicone_mock_client.py style: run black formatter on entire codebase 2026-03-11 17:07:57 -03:00
humanloop.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
lago.py fix: use fastuuid helper (#14903) 2025-09-25 15:47:01 -07:00
langsmith.py Merge pull request #26894 from BerriAI/litellm_langsmithRedactApiInfo 2026-05-04 09:55:59 -07:00
langsmith_mock_client.py style: run black formatter on entire codebase 2026-03-11 17:07:57 -03:00
langtrace.py build(pyproject.toml): add new dev dependencies - for type checking (#9631) 2025-03-29 11:02:13 -07:00
literal_ai.py fix: use fastuuid helper (#14903) 2025-09-25 15:47:01 -07:00
logfire_logger.py fix: use fastuuid helper (#14903) 2025-09-25 15:47:01 -07:00
lunary.py build(pyproject.toml): add new dev dependencies - for type checking (#9631) 2025-03-29 11:02:13 -07:00
mlflow.py Fix: MLflow streaming spans for Anthropic passthrough (#17288) 2025-12-05 14:59:36 -08:00
mock_client_factory.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
openmeter.py style: run black formatter on entire codebase 2026-03-11 17:07:57 -03:00
opentelemetry.py fix(otel): stamp http.response.status_code on all error responses (#28405) 2026-05-23 19:21:32 +00:00
posthog.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
posthog_mock_client.py style: run black formatter on entire codebase 2026-03-11 17:07:57 -03:00
prometheus.py feat(prometheus): emit per-token-type detail metrics (LIT-3220) (#28372) (#28378) 2026-05-23 12:17:42 -07:00
prometheus_services.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
prompt_layer.py LITELLM: Remove requests library usage (#7235) 2024-12-17 12:50:04 -08:00
prompt_management_base.py fix: trim caller-supplied dicts from compile_prompt error message 2026-04-29 15:16:01 -07:00
Readme.md (Feat) - Add GCS Pub/Sub Logging integration for sending DB SpendLogs to BigQuery (#7976) 2025-01-24 20:57:20 -08:00
rubrik.py Litellm oss staging 04 21 2026 2 (#26569) 2026-05-20 21:25:19 -07:00
s3.py Add allowing Key based prefix to s3 path (#16237) 2025-11-05 14:43:21 -08:00
s3_v2.py build(deps-dev): bump black to 26.3.1 and apply formatting (#28525) 2026-05-21 17:24:18 -07:00
sqs.py style: run black formatter on entire codebase 2026-03-11 17:07:57 -03:00
supabase.py (code quality) run ruff rule to ban unused imports (#7313) 2024-12-19 12:33:42 -08:00
test_httpx.py fix(utils.py): improved predibase exception mapping 2024-06-08 14:32:43 -07:00
traceloop.py (code quality) run ruff rule to ban unused imports (#7313) 2024-12-19 12:33:42 -08:00
weights_biases.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00

Integrations

This folder contains logging integrations for litellm

eg. logging to Datadog, Langfuse, Prometheus, s3, GCS Bucket, etc.