Skip to content

Commit 8786dca

Browse files
ref(litellm): Remove dead attributes (#5985)
Remove provider-specific `litellm` attributes that are not in `sentry-conventions` and that are not set in practice with current `litellm` versions. The `api_base`, `api_version` and `custom_llm_provider` values are stored in `litellm_params` and are not passed as top level keyword arguments to `litellm.input_callback` callbacks.
1 parent a0235d2 commit 8786dca

File tree

2 files changed

+0
-46
lines changed

2 files changed

+0
-46
lines changed

sentry_sdk/integrations/litellm.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,6 @@ def _input_callback(kwargs: "Dict[str, Any]") -> None:
159159
if value is not None:
160160
set_data_normalized(span, attribute, value)
161161

162-
# Record LiteLLM-specific parameters
163-
litellm_params = {
164-
"api_base": kwargs.get("api_base"),
165-
"api_version": kwargs.get("api_version"),
166-
"custom_llm_provider": kwargs.get("custom_llm_provider"),
167-
}
168-
for key, value in litellm_params.items():
169-
if value is not None:
170-
set_data_normalized(span, f"gen_ai.litellm.{key}", value)
171-
172162

173163
def _success_callback(
174164
kwargs: "Dict[str, Any]",

tests/integrations/litellm/test_litellm.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -532,42 +532,6 @@ def test_additional_parameters(sentry_init, capture_events):
532532
assert span["data"][SPANDATA.GEN_AI_REQUEST_PRESENCE_PENALTY] == 0.5
533533

534534

535-
def test_litellm_specific_parameters(sentry_init, capture_events):
536-
"""Test that LiteLLM-specific parameters are captured."""
537-
sentry_init(
538-
integrations=[LiteLLMIntegration()],
539-
traces_sample_rate=1.0,
540-
)
541-
events = capture_events()
542-
543-
messages = [{"role": "user", "content": "Hello!"}]
544-
mock_response = MockCompletionResponse()
545-
546-
with start_transaction(name="litellm test"):
547-
kwargs = {
548-
"model": "gpt-3.5-turbo",
549-
"messages": messages,
550-
"api_base": "https://custom-api.example.com",
551-
"api_version": "2023-01-01",
552-
"custom_llm_provider": "custom_provider",
553-
}
554-
555-
_input_callback(kwargs)
556-
_success_callback(
557-
kwargs,
558-
mock_response,
559-
datetime.now(),
560-
datetime.now(),
561-
)
562-
563-
(event,) = events
564-
(span,) = event["spans"]
565-
566-
assert span["data"]["gen_ai.litellm.api_base"] == "https://custom-api.example.com"
567-
assert span["data"]["gen_ai.litellm.api_version"] == "2023-01-01"
568-
assert span["data"]["gen_ai.litellm.custom_llm_provider"] == "custom_provider"
569-
570-
571535
def test_no_integration(sentry_init, capture_events):
572536
"""Test that when integration is not enabled, callbacks don't break."""
573537
sentry_init(

0 commit comments

Comments
 (0)