The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
refactor(otel): build promoted baggage without local dict mutation
yassin5e2d9e1d5c8e
diff --git a/litellm/integrations/otel/model/baggage.py b/litellm/integrations/otel/model/baggage.pyindex d380d868e90..131848e1380 100644--- a/litellm/integrations/otel/model/baggage.py+++ b/litellm/integrations/otel/model/baggage.py@@ -80,14 +80,12 @@ def promoted_baggage(``team_metadata_keys`` selects sub-keys of the team's metadata to promoteunder ``litellm.team.metadata``. Empty values are dropped."""- out: Final[dict[str, str]] = {}- for key, extract in _PROMOTABLE.items():- if key in promoted_keys:- value = extract(identity, request_model, team_metadata_keys)- if value:- out[key] = value- out.update(promoted_metadata(identity.metadata, metadata_keys))- return out+ identity_values: Final = {+ key: value+ for key, extract in _PROMOTABLE.items()+ if key in promoted_keys and (value := extract(identity, request_model, team_metadata_keys))+ }+ return {**identity_values, **promoted_metadata(identity.metadata, metadata_keys)}def promoted_metadata(metadata: Mapping[str, str], metadata_keys: tuple[str, ...]) -> Mapping[str, str]: