mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-11 08:38:24 +00:00
Merge 480ef0186b into 527d882508
This commit is contained in:
commit
9ee8f18c3f
2 changed files with 23 additions and 1 deletions
|
|
@ -2959,7 +2959,9 @@ class OpenTelemetry(OTELGenAISemconvMixin, CustomLogger):
|
|||
# gen_ai.* / metadata.* attributes — duplicating them here doubles
|
||||
# storage and adds noise (Issue #3).
|
||||
litellm_params: Final = kwargs.get("litellm_params", {}) or {}
|
||||
custom_llm_provider: Final = litellm_params.get("custom_llm_provider", "Unknown")
|
||||
custom_llm_provider: Final = (
|
||||
litellm_params.get("custom_llm_provider") or kwargs.get("custom_llm_provider") or "Unknown"
|
||||
)
|
||||
|
||||
_raw_response = kwargs.get("original_response")
|
||||
_additional_args: Final = kwargs.get("additional_args", {}) or {}
|
||||
|
|
|
|||
|
|
@ -3899,6 +3899,26 @@ class TestRawSpanAttributeIsolation(unittest.TestCase):
|
|||
)
|
||||
|
||||
|
||||
@patch("litellm.turn_off_message_logging", False)
|
||||
def test_raw_span_names_the_provider_when_only_the_call_details_carry_it(self):
|
||||
span_exporter: Final = InMemorySpanExporter()
|
||||
tracer_provider: Final = TracerProvider()
|
||||
tracer_provider.add_span_processor(SimpleSpanProcessor(span_exporter))
|
||||
otel: Final = OpenTelemetry(tracer_provider=tracer_provider)
|
||||
raw_span: Final = tracer_provider.get_tracer(__name__).start_span("raw_gen_ai_request")
|
||||
kwargs: Final = {
|
||||
"custom_llm_provider": "bedrock",
|
||||
"litellm_params": {"custom_llm_provider": None},
|
||||
"original_response": '{"images": ["aGVsbG8="]}',
|
||||
"additional_args": {"complete_input_dict": {"text_prompts": [{"text": "a red fox"}]}},
|
||||
}
|
||||
|
||||
otel.set_raw_request_attributes(raw_span, kwargs, None)
|
||||
raw_span.end()
|
||||
|
||||
(raw,) = span_exporter.get_finished_spans()
|
||||
self.assertEqual(set(raw.attributes or {}), {"llm.bedrock.text_prompts", "llm.bedrock.images"})
|
||||
|
||||
class TestNoParentSpanDuplication(unittest.TestCase):
|
||||
"""Issue #4: When litellm_request child span exists, the parent
|
||||
litellm_proxy_request span should NOT get set_attributes() called."""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue