mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-15 20:20:28 +00:00
* fix(prometheus): sanitize label values to prevent metric scrape failures Unicode characters like U+2028 (Line Separator) in Prometheus label values break the text exposition format, causing scrapers (e.g. Datadog) to fail parsing the entire /metrics endpoint. One bad label value causes ALL metrics to be lost, not just the affected metric. Add _sanitize_prometheus_label_value() and apply it in prometheus_label_factory() and all direct .labels() call sites. * fix(prometheus): handle non-string label values in sanitization Coerce non-string values (int, bool, float) to str before applying sanitization, preventing AttributeError on .replace() calls. * fix(prometheus): run sanitization on coerced non-string values Non-string values should be coerced to str and then sanitized (not returned early), so their string representations also get cleaned. * fix(prometheus): widen type hint to Optional[Any] for label value sanitization