Skip to content

fix(litellm): normalize the remaining LiteLLM provider prefixes to OTel gen_ai.provider.name values - #4407

Open
Anai-Guo wants to merge 1 commit into
traceloop:mainfrom
Anai-Guo:fix/litellm-provider-aliases
Open

fix(litellm): normalize the remaining LiteLLM provider prefixes to OTel gen_ai.provider.name values#4407
Anai-Guo wants to merge 1 commit into
traceloop:mainfrom
Anai-Guo:fix/litellm-provider-aliases

Conversation

@Anai-Guo

@Anai-Guo Anai-Guo commented Aug 10, 2026

Copy link
Copy Markdown

What

_PROVIDER_ALIASES in the LiteLLM instrumentation normalizes LiteLLM's provider prefixes onto the OTel gen_ai.provider.name well-known values. It covered six prefixes; several other prefixes that LiteLLM reports as custom_llm_provider also differ from the published values and were passing through unchanged:

LiteLLM custom_llm_provider emitted before emitted now
watsonx watsonx ibm.watsonx.ai
watsonx_text watsonx_text ibm.watsonx.ai
xai xai x_ai
cohere_chat cohere_chat cohere
vertex_ai_beta vertex_ai_beta gcp.vertex_ai
azure_text azure_text azure.ai.openai
bedrock_mantle bedrock_mantle aws.bedrock

Why

This split one provider across two keys depending on the route taken. A watsonx call made through LiteLLM was recorded as watsonx, while the same call through this repo's watsonx instrumentation is recorded as ibm.watsonx.ai (GenAiSystemValues.IBM_WATSONX_AI) — so spans and metrics for the same provider don't aggregate together, which is exactly what the comment above the table says the normalization is there to prevent. The same applies to cohere_chat vs the cohere instrumentation's cohere, and to the vertex_ai_beta / azure_text / bedrock_mantle variants of prefixes that were already normalized.

All seven are real, distinct custom_llm_provider values, verified against LiteLLM 1.94.0:

>>> from litellm import get_llm_provider
>>> get_llm_provider(model="watsonx/ibm/granite-13b-chat-v2")[1]
'watsonx'
>>> get_llm_provider(model="xai/grok-4")[1]
'xai'
>>> get_llm_provider(model="bedrock_mantle/openai.gpt-5.4")[1]
'bedrock_mantle'

Each maps onto an existing GenAiProviderNameValues member, so no new values are invented. Unknown prefixes still pass through unchanged, as before.

Testing

tests/test_provider_resolution.py is parametrized over the new prefixes. Verified old-vs-new against the same test file:

  • On main (fix reverted, new tests in place): 7 failed, 10 passed — each failure is the raw prefix leaking through, e.g. assert 'xai' == 'x_ai'.
  • With the fix: 17 passed.

Full package suite: 37 passed, 1 skipped (the skip is the pre-existing test_both_openai_and_litellm_instrumented, which needs opentelemetry-instrumentation-openai installed). ruff check clean under the package's config.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved provider detection for additional LiteLLM aliases, including Azure Text, Bedrock Mantle, Cohere Chat, Vertex AI Beta, WatsonX, and xAI.
    • Ensured these provider variants are consistently reported with the correct OpenTelemetry provider values.

…el values

The provider alias table normalized six LiteLLM prefixes, but several other
prefixes that LiteLLM reports as custom_llm_provider also differ from the
published gen_ai.provider.name values and were passing through unchanged:

- watsonx / watsonx_text -> ibm.watsonx.ai
- xai -> x_ai
- cohere_chat -> cohere
- vertex_ai_beta -> gcp.vertex_ai
- azure_text -> azure.ai.openai
- bedrock_mantle -> aws.bedrock

This split the same provider across two keys depending on the route taken: a
watsonx call made through LiteLLM was recorded as watsonx while the same
call through the watsonx instrumentation was recorded as ibm.watsonx.ai,
so spans and metrics for one provider no longer aggregate together.

All seven prefixes are real custom_llm_provider values in LiteLLM (verified
with litellm.get_llm_provider on 1.94.0), and each maps onto an existing
GenAiProviderNameValues member. Unknown prefixes still pass through
unchanged.
@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.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 74088a35-59f6-4672-b5cf-73bc263ca434

📥 Commits

Reviewing files that changed from the base of the PR and between c2f3f45 and 73106f8.

📒 Files selected for processing (2)
  • packages/opentelemetry-instrumentation-litellm/opentelemetry/instrumentation/litellm/__init__.py
  • packages/opentelemetry-instrumentation-litellm/tests/test_provider_resolution.py

📝 Walkthrough

Walkthrough

The LiteLLM instrumentation now normalizes additional provider aliases. Parameterized tests verify the expected OpenTelemetry provider values.

Changes

LiteLLM provider aliases

Layer / File(s) Summary
Provider alias normalization and coverage
packages/opentelemetry-instrumentation-litellm/opentelemetry/instrumentation/litellm/__init__.py, packages/opentelemetry-instrumentation-litellm/tests/test_provider_resolution.py
Added aliases for Azure Text, Bedrock Mantle, Cohere Chat, Vertex AI Beta, WatsonX, and XAI. Added tests for each normalized provider value.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: normalizing remaining LiteLLM provider prefixes to OpenTelemetry provider names.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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