Skip to content

fix(proxy): register a UI-configured arize callback next to otel under OTel v2 - #43906

Merged
yassin-berriai merged 1 commit into
mainfrom
litellm_lit9070_ui_arize_otel_v2_dedupe
Sep 30, 2026
Merged

yassin-berriai merged 1 commit into
mainfrom
litellm_lit9070_ui_arize_otel_v2_dedupe

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Arize added from the Admin UI never sends traces when OTel v2 is on and otel is already configured
  • Nothing is logged: the callback is silently dropped as a duplicate of otel

How it solves it:

  • Duplicate check for UI/DB callbacks now compares class and callback name, not class alone
  • otel and arize (both OpenTelemetryV2 under OTel v2) register side by side; re-adding the same preset is still skipped

User Flow

Before: a proxy admin running with LITELLM_OTEL_V2=true and callbacks: ["otel"] in config.yaml adds Arize in the UI and no trace ever shows up in Arize

  1. They open http://localhost:4000/ui/?page=logging-callbacks, click Add Callback, pick Arize, fill in the space id and API key, and save. The page shows Arize in the callback list
  2. They send POST http://localhost:4000/v1/chat/completions with {"model": "fake-gpt", "messages": [...]} and get a 200
  3. Their OTel collector receives the spans for that request. Their Arize project stays empty, and the proxy logs nothing about Arize being skipped

After: the same UI setup delivers the request span to Arize

  1. They open http://localhost:4000/ui/?page=logging-callbacks, click Add Callback, pick Arize, fill in the space id and API key, and save. The page shows Arize in the callback list
  2. They send POST http://localhost:4000/v1/chat/completions with {"model": "fake-gpt", "messages": [...]} and get a 200
  3. Their OTel collector receives the spans for that request, and their Arize project receives the chat fake-gpt span for the same request, carrying the space id and API key they entered

Files changed

File What changed and why
litellm/utils.py _custom_logger_class_exists_in_success_callbacks and _custom_logger_class_exists_in_failure_callbacks now go through a new _is_same_registered_custom_logger helper that matches on the exact class and the instance's callback_name. One class can back several callback names (every OTel v2 preset is an OpenTelemetryV2), so a registered otel no longer counts as an already registered arize. Loggers without a callback_name compare None == None and keep the previous class-only behavior

Linear ticket

Resolves LIT-9070

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. 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
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to 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 (the LiteLLM_Config row holds litellm_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 yaml otel callback (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 Arize space_id / api_key headers were present

# config_v2.yaml
model_list:
  - model_name: fake-gpt
    litellm_params:
      model: openai/fake-gpt
      api_key: fake
      mock_response: "hello from fake-gpt"

general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY
  store_model_in_db: true

litellm_settings:
  set_verbose: false
  callbacks: ["otel"]
LITELLM_OTEL_V2=true litellm --config config_v2.yaml --port 4000

Before (264b09a)

  1. Send one chat request
$ curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:4000/v1/chat/completions \
    -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "content-type: application/json" \
    -d '{"model":"fake-gpt","messages":[{"role":"user","content":"ping-v2-otel-plus-ui-arize"}]}'
200
  1. The Arize receiver got nothing
$ cat sink_arize.log
(end arize sink, 0 lines)
  1. The otel receiver got the request's spans, so the request was logged and only the UI-added Arize callback was missing
$ 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)

  1. Send the same chat request
$ curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:4000/v1/chat/completions \
    -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "content-type: application/json" \
    -d '{"model":"fake-gpt","messages":[{"role":"user","content":"ping-v2-otel-plus-ui-arize"}]}'
200
  1. The Arize receiver got the chat span with the UI-entered space id and API key headers
$ 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"]}
  1. The otel receiver still gets its spans, unchanged
$ 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_names kills all four mutants tried on the new helper (class only, name only, always false, isinstance instead of exact type), and tests/test_litellm/proxy/test_proxy_server.py::test_db_config_sync_registers_otel_v2_arize_next_to_otel drives the DB/UI registration path for both success_callback and failure_callback and fails on the class-only check

Type

🐛 Bug Fix

Caveats (if any)

Medium

  • Proof uses local OTLP receivers standing in for Arize and the collector, not the hosted Arize endpoint. What is verified is that the export leaves the proxy with the Arize headers; the hosted ingest path is unchanged by this PR

Low

  • Legacy OpenTelemetry also sets callback_name per preset (langtrace, langfuse_otel, weave_otel), so two legacy OTel presets added from the UI now register side by side as well
  • The same-callback-name path (UI arize saved twice, or config re-applied) was checked in the regression test, which applies the DB config twice and still sees one arize

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

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 same OpenTelemetryV2 class.

Duplicate guards in litellm/utils.py (_custom_logger_class_exists_in_success_callbacks and _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 and callback_name both match. Sibling presets register side by side; re-adding the same preset is still skipped. Loggers without callback_name keep prior behavior via None == None.

Regression coverage adds unit tests for the guard logic and a proxy test that arize syncs from DB config next to otel for success and failure paths.

Reviewed by Cursor Bugbot for commit c05a715. Bugbot is set up for automated code reviews on this repo. Configure here.

…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>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@codecov

codecov Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Refines callback deduplication logic for observability integrations.

The PR appears safe to merge based on the reviewed callback registration paths and tests.

Summary

The PR changes custom-logger duplicate detection to compare both exact class and callback name, allowing UI-configured Arize and an existing OTel v2 callback to register together.

  • Adds unit coverage for callback identity and proxy DB-configuration coverage for success and failure registration.

Reviews (1) · Last reviewed commit: "fix(proxy): register a UI-configured ari..."

@codspeed

codspeed Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_lit9070_ui_arize_otel_v2_dedupe (c05a715) with main (50f5cc9)

Open in CodSpeed

@yassin-berriai

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.

@yassin-berriai
yassin-berriai merged commit e662772 into main Sep 30, 2026
104 of 107 checks passed
@yassin-berriai
yassin-berriai deleted the litellm_lit9070_ui_arize_otel_v2_dedupe branch September 30, 2026 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants