Skip to content

fix(otel): promote litellm.request.model via baggage instead of gen_ai.request.model - #35228

Closed
nishant-uxs wants to merge 4 commits into
BerriAI:litellm_internal_stagingfrom
nishant-uxs:fix/otel-v2-baggage-request-model-35193
Closed

fix(otel): promote litellm.request.model via baggage instead of gen_ai.request.model#35228
nishant-uxs wants to merge 4 commits into
BerriAI:litellm_internal_stagingfrom
nishant-uxs:fix/otel-v2-baggage-request-model-35193

Conversation

@nishant-uxs

Copy link
Copy Markdown

Summary

  • Stop promoting canonical gen_ai.request.model through OpenTelemetry Baggage by default.
  • Promote litellm.request.model instead so SERVER / DB / service / guardrail spans can correlate the inbound model without being classified as GenAI operations.
  • LLM-call spans still receive gen_ai.request.model from the GenAI mapper.

Fixes #35193

Notes

  • Targets litellm_internal_staging as required for external fork contributions.
  • Diff is 4 files / 1 commit only.

Test plan

  • pytest tests/test_litellm/integrations/otel/test_otel_v2_baggage.py
  • pytest tests/test_litellm/integrations/otel/test_otel_v2_sources_of_truth.py::test_promoted_baggage_is_bounded_allowlist
  • pytest tests/test_litellm/integrations/otel/test_otel_v2_emitter.py::test_llm_call_span_golden
  • pytest tests/test_litellm/integrations/otel/test_otel_v2_config_baggage_parenting_guardrails.py

…i.request.model

Baggage promotion stamped canonical gen_ai.request.model onto SERVER, DB, and service spans, causing GenAI backends to misclassify non-LLM operations. Use litellm.request.model for cross-span correlation; LLM-call spans still receive gen_ai.request.model from the GenAI mapper.

Fixes BerriAI#35193
@CLAassistant

CLAassistant commented Jul 30, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

LiteLLM.KEY_HASH: lambda identity, model, team_metadata_keys: identity.key_hash,
LiteLLM.END_USER: lambda identity, model, team_metadata_keys: identity.end_user,
GenAI.REQUEST_MODEL: lambda identity, model, team_metadata_keys: model,
LiteLLM.REQUEST_MODEL: lambda identity, model, team_metadata_keys: model,

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.

P1 Legacy allowlists silently lose models

When an existing deployment explicitly configures baggage_promoted_keys with gen_ai.request.model, promoted_baggage no longer has an extractor for that configured key and silently omits it, causing downstream non-LLM span processors and correlations to lose the request model after upgrading. Please retain compatibility for the old configured value or reject it with an actionable configuration error.

Rule Used: What: avoid backwards-incompatible changes without... (source)

@greptile-apps

greptile-apps Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Updates OpenTelemetry baggage model correlation semantics.

  • Adds the vendor-specific litellm.request.model semantic-convention key.
  • Promotes that key instead of gen_ai.request.model through baggage.
  • Keeps the canonical GenAI attribute restricted to LLM-call spans and updates coverage for the distinction.

Confidence Score: 4/5

The explicit legacy baggage-allowlist behavior needs compatibility handling or validation before this PR is safe to merge.

Existing deployments can configure gen_ai.request.model for promotion, but the changed extractor table no longer recognizes that value and silently drops the request model from propagated baggage.

Files Needing Attention: litellm/integrations/otel/model/baggage.py

Important Files Changed

Filename Overview
litellm/integrations/otel/model/baggage.py Changes the request-model promotion key, but existing explicit allowlists using the former key are now silently ignored.
litellm/integrations/otel/model/semconv.py Defines and documents the new vendor-specific request-model attribute.
tests/test_litellm/integrations/otel/test_otel_v2_baggage.py Verifies the intended span attributes, but does not cover compatibility with explicitly configured legacy allowlists.
tests/test_litellm/integrations/otel/test_otel_v2_sources_of_truth.py Updates the bounded default-allowlist assertion to the new key.

Reviews (1): Last reviewed commit: "fix(otel): promote litellm.request.model..." | Re-trigger Greptile

@nishant-uxs

Copy link
Copy Markdown
Author

recheck

@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed-hq

codspeed-hq Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing nishant-uxs:fix/otel-v2-baggage-request-model-35193 (737cc65) with litellm_internal_staging (71b825a)

Open in CodSpeed

Deployments that still list gen_ai.request.model in baggage_promoted_keys keep model correlation via litellm.request.model instead of silently dropping it.
@nishant-uxs

Copy link
Copy Markdown
Author

Addressed the Greptile P1: legacy baggage_promoted_keys entries that still list gen_ai.request.model are remapped to litellm.request.model so model correlation is preserved without promoting the canonical GenAI attribute onto non-LLM spans.

LIT001 rejected list[str]/set[str] locals in _normalize_promoted_keys. Use tuple-only dedupe so the type-discipline budget stays flat.
@nishant-uxs

Copy link
Copy Markdown
Author

Closing this PR to keep the LiteLLM surface focused on the higher-value streaming fix in #35349.

This otel baggage change no longer justifies a second conflicting PR on litellm_internal_staging. Happy to reopen a fresh branch later if maintainers still want the baggage remap as a standalone change.

@nishant-uxs nishant-uxs closed this Aug 7, 2026
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.

[Bug]: OTel v2 promotes gen_ai.request.model onto non-LLM spans

2 participants