fix(litellm): Set operation name from call type instead of chat fallback#6792
Open
VihaanAgarwal wants to merge 1 commit into
Open
fix(litellm): Set operation name from call type instead of chat fallback#6792VihaanAgarwal wants to merge 1 commit into
VihaanAgarwal wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6442.
The input callback mapped every call type except
embedding/aembeddingtochat, so alitellm.image_generation()call showed up in Sentry aschat dall-e-3withgen_ai.operation.name: chat. Same story for text completions, speech, transcription, rerank and the rest.This replaces the binary fallback with an explicit table of the call types we can name accurately:
completion/acompletion->chattext_completion/atext_completion->text_completionembedding/aembedding->embeddingsresponses/aresponses->responsesEach maps to its matching
OP.GEN_AI_*span op (the constants fortext_completionandresponsesalready exist and are used by the langchain and openai integrations).For everything else,
gen_ai.operation.nameis simply not set. Recording a guess is what this issue is about, and litellm has 140+ call types (batch, files, assistants, video...), most of which have no semconv equivalent. The raw call type still ends up in the span name (image_generation dall-e-3), so the spans stay identifiable. I keptgen_ai.chatas the span op fallback for unmapped types so those spans keep flowing into the AI views like before; happy to change that if you'd rather they drop out.One test tweak:
test_response_without_usagebuilt callback kwargs without acall_typeand asserted the span was namedchat ..., which only held because of the fallback. Real callbacks always carrycall_type(litellm'sLogging.pre_callsets it), so I added"call_type": "completion"to those kwargs rather than special casing a missing key as chat.Tests cover all eight mapped call types plus the unknown case. The litellm test module passes locally except
test_multiple_providers, which errors at setup on current master too (missing optional provider package in my env).