Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"extract_attributes_from_frame",
"extract_service_attributes",
"detect_service_type",
"detect_service_type_from_class_string",
"detect_provider_from_service",
]

Expand Down Expand Up @@ -121,6 +122,27 @@ def detect_service_type(service: FrameProcessor) -> str:
return "unknown"


def detect_service_type_from_class_string(service: str) -> str:
"""
Detect the type of service from string. MetricsFrames use a string
to identify processor, so we use this method to determine service type

Args:
service: str, ie `GoogleLLMService`

Returns:
Service type
"""
service_type = "unknown"
if "STTService" in service:
service_type = "stt"
elif "LLMService" in service:
service_type = "llm"
elif "TTSService" in service:
service_type = "tts"
return service_type


def detect_provider_from_service(service: FrameProcessor) -> str:
"""Detect the provider from a service."""
try:
Expand Down Expand Up @@ -747,7 +769,8 @@ class LLMServiceAttributeExtractor(ServiceAttributeExtractor):
SpanAttributes.OPENINFERENCE_SPAN_KIND: lambda service: (
OpenInferenceSpanKindValues.LLM.value
),
SpanAttributes.LLM_MODEL_NAME: lambda service: getattr(service, "model_name", None)
SpanAttributes.LLM_MODEL_NAME: lambda service: getattr(service, "_full_model_name", None)
or getattr(service, "model_name", None)
or getattr(service, "model", None),
SpanAttributes.LLM_PROVIDER: lambda service: detect_provider_from_service(service),
# GenAI semantic conventions (dual attributes)
Expand Down
Loading
Loading