mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-14 23:21:35 +00:00
litellm_guardrail_latency_seconds was only emitted for pre-call guardrails. during_call_hook and post_call_success_hook ran guardrails without recording any latency, so during-call and post-call guardrail time was invisible in the metric and leaked into litellm_overhead_latency_metric, making the documented "subtract guardrail latency from overhead" workaround under-report total guardrail time. Extract the find-the-PrometheusLogger-and-record step into _emit_guardrail_metrics and add _run_guardrail_with_metrics, a single wrapper that times a guardrail coroutine, classifies its outcome (success / intervened / error), enriches any raised HTTPException, and records the latency under the given hook_type. Route the pre-call emit, during_call_hook, and post_call_success_hook through it so every guardrail phase contributes to the metric the same way. Resolves LIT-3999 |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| _harness_smoke_test.py | ||
| conftest.py | ||
| test_alerting.py | ||
| test_callback_capabilities_class.py | ||
| test_callback_capabilities_dataclass.py | ||
| test_during_call_hook.py | ||
| test_guardrail_pipeline.py | ||
| test_internal_usage_cache.py | ||
| test_lifecycle.py | ||
| test_mcp_bridging.py | ||
| test_module_helpers.py | ||
| test_post_call_failure_hook.py | ||
| test_post_call_success_hook.py | ||
| test_pre_call_hook.py | ||
| test_streaming_hooks.py | ||