Update OTel attribute names
This commit is contained in:
@@ -45,7 +45,7 @@ def add_tts_span_attributes(
|
|||||||
**kwargs: Additional attributes to add
|
**kwargs: Additional attributes to add
|
||||||
"""
|
"""
|
||||||
# Add standard attributes
|
# Add standard attributes
|
||||||
span.set_attribute("service.name", service_name)
|
span.set_attribute("service", service_name)
|
||||||
span.set_attribute("model", model)
|
span.set_attribute("model", model)
|
||||||
span.set_attribute("voice_id", voice_id)
|
span.set_attribute("voice_id", voice_id)
|
||||||
span.set_attribute("operation", operation_name)
|
span.set_attribute("operation", operation_name)
|
||||||
@@ -55,7 +55,7 @@ def add_tts_span_attributes(
|
|||||||
span.set_attribute("text", text)
|
span.set_attribute("text", text)
|
||||||
|
|
||||||
if character_count is not None:
|
if character_count is not None:
|
||||||
span.set_attribute("metrics.tts.character_count", character_count)
|
span.set_attribute("metrics.character_count", character_count)
|
||||||
|
|
||||||
if ttfb_ms is not None:
|
if ttfb_ms is not None:
|
||||||
span.set_attribute("metrics.ttfb_ms", ttfb_ms)
|
span.set_attribute("metrics.ttfb_ms", ttfb_ms)
|
||||||
@@ -99,7 +99,7 @@ def add_stt_span_attributes(
|
|||||||
**kwargs: Additional attributes to add
|
**kwargs: Additional attributes to add
|
||||||
"""
|
"""
|
||||||
# Add standard attributes
|
# Add standard attributes
|
||||||
span.set_attribute("service.name", service_name)
|
span.set_attribute("service", service_name)
|
||||||
span.set_attribute("model", model)
|
span.set_attribute("model", model)
|
||||||
span.set_attribute("vad_enabled", vad_enabled)
|
span.set_attribute("vad_enabled", vad_enabled)
|
||||||
|
|
||||||
@@ -161,13 +161,13 @@ def add_llm_span_attributes(
|
|||||||
**kwargs: Additional attributes to add
|
**kwargs: Additional attributes to add
|
||||||
"""
|
"""
|
||||||
# Add standard attributes
|
# Add standard attributes
|
||||||
span.set_attribute("service.name", service_name)
|
span.set_attribute("service", service_name)
|
||||||
span.set_attribute("model", model)
|
span.set_attribute("model", model)
|
||||||
span.set_attribute("stream", stream)
|
span.set_attribute("stream", stream)
|
||||||
|
|
||||||
# Add optional attributes
|
# Add optional attributes
|
||||||
if messages:
|
if messages:
|
||||||
span.set_attribute("messages", messages)
|
span.set_attribute("input", messages)
|
||||||
|
|
||||||
if tools:
|
if tools:
|
||||||
span.set_attribute("tools", tools)
|
span.set_attribute("tools", tools)
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ def _get_service_name(self, service_prefix: str) -> str:
|
|||||||
A default span name string like "type_classname" (e.g. llm_openaillmservice).
|
A default span name string like "type_classname" (e.g. llm_openaillmservice).
|
||||||
"""
|
"""
|
||||||
service_class_name = self.__class__.__name__.lower()
|
service_class_name = self.__class__.__name__.lower()
|
||||||
return f"{service_prefix}_{service_class_name}"
|
return f"{service_prefix}"
|
||||||
|
|
||||||
|
|
||||||
def _add_token_usage_to_span(span, token_usage):
|
def _add_token_usage_to_span(span, token_usage):
|
||||||
@@ -93,13 +93,19 @@ def _add_token_usage_to_span(span, token_usage):
|
|||||||
|
|
||||||
if isinstance(token_usage, dict):
|
if isinstance(token_usage, dict):
|
||||||
if "prompt_tokens" in token_usage:
|
if "prompt_tokens" in token_usage:
|
||||||
span.set_attribute("llm.prompt_tokens", token_usage["prompt_tokens"])
|
span.set_attribute("llm.token_count.prompt_tokens", token_usage["prompt_tokens"])
|
||||||
if "completion_tokens" in token_usage:
|
if "completion_tokens" in token_usage:
|
||||||
span.set_attribute("llm.completion_tokens", token_usage["completion_tokens"])
|
span.set_attribute(
|
||||||
|
"llm.token_count.completion_tokens", token_usage["completion_tokens"]
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
# Handle LLMTokenUsage object
|
# Handle LLMTokenUsage object
|
||||||
span.set_attribute("llm.prompt_tokens", getattr(token_usage, "prompt_tokens", 0))
|
span.set_attribute(
|
||||||
span.set_attribute("llm.completion_tokens", getattr(token_usage, "completion_tokens", 0))
|
"llm.token_count.prompt_tokens", getattr(token_usage, "prompt_tokens", 0)
|
||||||
|
)
|
||||||
|
span.set_attribute(
|
||||||
|
"llm.token_count.completion_tokens", getattr(token_usage, "completion_tokens", 0)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def traced_tts(func: Optional[Callable] = None, *, name: Optional[str] = None) -> Callable:
|
def traced_tts(func: Optional[Callable] = None, *, name: Optional[str] = None) -> Callable:
|
||||||
|
|||||||
Reference in New Issue
Block a user