Repository navigation
fix(proxy): register a UI-configured arize callback next to otel under OTel v2 - #43906
Conversation
…r OTel v2 Callbacks saved from the Admin UI reach litellm through _add_custom_logger_callback_to_specific_event, which skipped the freshly built logger whenever a callback of the same exact class was already registered. With LITELLM_OTEL_V2 enabled every OTel preset (otel, arize, ...) is an OpenTelemetryV2, so a UI-added arize was treated as a duplicate of the yaml otel callback and never attached, and no trace ever reached Arize The exists check now compares the exact class and the logger's callback_name, so presets that share a class register side by side while a true re-registration of the same preset is still skipped Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit c05a715. Configure here.
TLDR
Problem this solves:
otelis already configuredotelHow it solves it:
otelandarize(bothOpenTelemetryV2under OTel v2) register side by side; re-adding the same preset is still skippedUser Flow
Before: a proxy admin running with
LITELLM_OTEL_V2=trueandcallbacks: ["otel"]in config.yaml adds Arize in the UI and no trace ever shows up in Arize{"model": "fake-gpt", "messages": [...]}and get a 200After: the same UI setup delivers the request span to Arize
{"model": "fake-gpt", "messages": [...]}and get a 200chat fake-gptspan for the same request, carrying the space id and API key they enteredFiles changed
litellm/utils.py_custom_logger_class_exists_in_success_callbacksand_custom_logger_class_exists_in_failure_callbacksnow go through a new_is_same_registered_custom_loggerhelper that matches on the exact class and the instance'scallback_name. One class can back several callback names (every OTel v2 preset is anOpenTelemetryV2), so a registeredotelno longer counts as an already registeredarize. Loggers without acallback_namecompareNone == Noneand keep the previous class-only behaviorLinear ticket
Resolves LIT-9070
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Screenshots / Proof of Fix
Shared setup for both runs. The proxy runs against Postgres with
store_model_in_db: true, the Arize callback was saved through the UI callback flow (theLiteLLM_Configrow holdslitellm_settings = {"success_callback": ["arize"]}plus the Arize env vars), and two local OTLP HTTP receivers stand in for the two destinations: port 4318 for Arize (ARIZE_HTTP_ENDPOINT=http://127.0.0.1:4318/v1/traces) and port 4319 for the yamlotelcallback (OTEL_EXPORTER=otlp_http,OTEL_ENDPOINT=http://127.0.0.1:4319/v1/traces). Each receiver appends one JSON line per OTLP export it gets, with the span names and whether the Arizespace_id/api_keyheaders were presentBefore (264b09a)
$ cat sink_otel.log {"t": 1790795900.03, "path": "/v1/traces", "space_id": null, "api_key_set": false, "n_spans": 4, "spans": ["auth /v1/chat/completions", "chat fake-gpt", "batch_write_to_db _PROXY_track_cost_callback", "POST /v1/chat/completions"]}After (c05a715)
$ cat sink_arize.log {"t": 1790795961.15, "path": "/v1/traces", "space_id": "test-space-id", "api_key_set": true, "n_spans": 1, "spans": ["chat fake-gpt"]}$ cat sink_otel.log {"t": 1790795961.10, "path": "/v1/traces", "space_id": null, "api_key_set": false, "n_spans": 4, "spans": ["auth /v1/chat/completions", "chat fake-gpt", "batch_write_to_db _PROXY_track_cost_callback", "POST /v1/chat/completions"]} {"t": 1790795961.15, "path": "/v1/traces", "space_id": null, "api_key_set": false, "n_spans": 1, "spans": ["chat fake-gpt"]}Regression tests:
tests/unit/test_utils.py::test_custom_logger_guards_distinguish_callback_nameskills all four mutants tried on the new helper (class only, name only, always false,isinstanceinstead of exact type), andtests/test_litellm/proxy/test_proxy_server.py::test_db_config_sync_registers_otel_v2_arize_next_to_oteldrives the DB/UI registration path for bothsuccess_callbackandfailure_callbackand fails on the class-only checkType
🐛 Bug Fix
Caveats (if any)
Medium
Low
OpenTelemetryalso setscallback_nameper preset (langtrace,langfuse_otel,weave_otel), so two legacy OTel presets added from the UI now register side by side as wellarizeFinal Attestation
Link to Devin session: https://app.devin.ai/sessions/2f3d0c9b620940eabacdc0b1849d1d03
Open in Devin Desktop: https://app.devin.ai/desktop/session/2f3d0c9b620940eabacdc0b1849d1d03?variant=devin
Requested by: @yassin-berriai
Note
Medium Risk
Changes core callback registration deduplication used by proxy DB/UI config; behavior shifts for multi-preset OTel loggers but is narrowly scoped with strong regression tests.
Overview
Fixes silent dropping of Admin UI / DB callbacks such as Arize when OTel v2 is enabled and another preset (e.g.
otel) is already registered—both share the sameOpenTelemetryV2class.Duplicate guards in
litellm/utils.py(_custom_logger_class_exists_in_success_callbacksand_custom_logger_class_exists_in_failure_callbacks) now delegate to_is_same_registered_custom_logger, which treats a logger as already registered only when exact class andcallback_nameboth match. Sibling presets register side by side; re-adding the same preset is still skipped. Loggers withoutcallback_namekeep prior behavior viaNone == None.Regression coverage adds unit tests for the guard logic and a proxy test that
arizesyncs from DB config next tootelfor success and failure paths.Reviewed by Cursor Bugbot for commit c05a715. Bugbot is set up for automated code reviews on this repo. Configure here.