Skip to content

Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.

[Feat]: Refactor Agno OpenTelemetry Monitoring instrumentation (#823)

Patcher5a12ee35f582
diff --git a/.gitignore b/.gitignore
index 346c3a18..2beadaac 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,6 @@ path/
__pycache__/
**bun.lockb
logs/
-
+.env
.vscode/
.idea/
\ No newline at end of file
diff --git a/agno-repo b/agno-repo
new file mode 160000
index 00000000..c33fb931
--- /dev/null
+++ b/agno-repo
@@ -0,0 +1 @@
+Subproject commit c33fb931500a18b987e43795c0d32f8e7baf3835
diff --git a/agno-source b/agno-source
new file mode 160000
index 00000000..1193c45d
--- /dev/null
+++ b/agno-source
@@ -0,0 +1 @@
+Subproject commit 1193c45dccb0090e972bb1cacffc44295d1d4fe8
diff --git a/sdk/python/.pylintrc b/sdk/python/.pylintrc
index f5cffa4f..5c19961e 100644
--- a/sdk/python/.pylintrc
+++ b/sdk/python/.pylintrc
@@ -4,10 +4,10 @@
max-locals=30
# Maximum number of arguments for function / method
-max-args=25
+max-args=26
# Maximum number of positional arguments (see R0917).
-max-positional-arguments=20
+max-positional-arguments=21
# Maximum allowed line length
max-line-length=135
@@ -33,4 +33,6 @@ disable=
no-member,
no-else-return,
import-outside-toplevel,
- too-many-return-statements
\ No newline at end of file
+ too-many-return-statements,
+ too-many-function-args
+
\ No newline at end of file
diff --git a/sdk/python/pyproject.toml b/sdk/python/pyproject.toml
index b3a13acc..15999ae0 100644
--- a/sdk/python/pyproject.toml
+++ b/sdk/python/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "openlit"
-version = "1.34.35"
+version = "1.34.36"
description = "OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications and GPUs, facilitating the integration of observability into your GenAI-driven projects"
authors = ["OpenLIT"]
license = "Apache-2.0"
diff --git a/sdk/python/src/openlit/_instrumentors.py b/sdk/python/src/openlit/_instrumentors.py
index 05ed5024..7112fb4b 100644
--- a/sdk/python/src/openlit/_instrumentors.py
+++ b/sdk/python/src/openlit/_instrumentors.py
@@ -36,7 +36,7 @@ MODULE_NAME_MAP = {
"pyautogen": "pyautogen",
"multion": "multion",
"dynamiq": "dynamiq",
- "phidata": "phi",
+ "agno": "agno",
"reka-api": "reka",
"premai": "premai",
"julep": "julep",
@@ -84,7 +84,7 @@ INSTRUMENTOR_MAP = {
"autogen": "openlit.instrumentation.ag2.AG2Instrumentor",
"pyautogen": "openlit.instrumentation.ag2.AG2Instrumentor",
"dynamiq": "openlit.instrumentation.dynamiq.DynamiqInstrumentor",
- "phidata": "openlit.instrumentation.phidata.PhidataInstrumentor",
+ "agno": "openlit.instrumentation.agno.AgnoInstrumentor",
"reka-api": "openlit.instrumentation.reka.RekaInstrumentor",
"premai": "openlit.instrumentation.premai.PremAIInstrumentor",
"julep": "openlit.instrumentation.julep.JulepInstrumentor",
diff --git a/sdk/python/src/openlit/instrumentation/agno/__init__.py b/sdk/python/src/openlit/instrumentation/agno/__init__.py
new file mode 100644
index 00000000..4f5f3ac4
--- /dev/null
+++ b/sdk/python/src/openlit/instrumentation/agno/__init__.py
@@ -0,0 +1,652 @@
+"""Initializer of Auto Instrumentation of Agno Framework Functions"""
+
+from typing import Collection
+import importlib.metadata
+from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
+from wrapt import wrap_function_wrapper
+
+from openlit.instrumentation.agno.agno import (
+ agent_run_wrap,
+ agent_continue_run_wrap,
+ agent_run_tool_wrap,
+ agent_add_tool_wrap,
+ session_memory_wrap,
+ memory_add_wrap,
+ memory_search_wrap,
+ function_execute_wrap,
+ reasoning_wrap,
+ vectordb_search_wrap,
+ vectordb_upsert_wrap,
+ knowledge_search_wrap,
+ knowledge_add_wrap,
+ workflow_run_wrap,
+ team_run_wrap,
+ model_run_function_call_wrap,
+ function_entrypoint_wrap,
+ memory_operation_wrap,
+ parallel_execution_wrap,
+ reasoning_tool_wrap,
+)
+from openlit.instrumentation.agno.async_agno import (
+ async_agent_run_wrap,
+ async_agent_continue_run_wrap,
+ async_function_execute_wrap,
+ async_reasoning_wrap,
+ async_workflow_run_wrap,
+ async_team_run_wrap,
+ async_model_run_function_call_wrap,
+ async_function_entrypoint_wrap,
+)
+
+_instruments = ("agno >= 0.6.0",)
+
+WORKFLOW_OPERATIONS = [
+ # Core Agent Execution Methods
+ "Agent.run",
+ "Agent.continue_run",
+ # Team Operations
+ "Agent.create",
+]
+
+COMPONENT_OPERATIONS = [
+ # Tool Management
+ "Agent.add_tool",
+ "Agent.set_tools",
+ # Memory Operations
+ "Agent.get_session_summary",
+ "Agent.get_user_memories",
+]
+
+
+class AgnoInstrumentor(BaseInstrumentor):
+ """
+ An instrumentor for Agno Framework's agent library.
+ """
+
+ def __init__(self):
+ """Initialize the AgnoInstrumentor."""
+ super().__init__()
+ self._original_thread_pool_submit = None
+
+ def instrumentation_dependencies(self) -> Collection[str]:
+ return _instruments
+
+ def _instrument(self, **kwargs):
+ application_name = kwargs.get("application_name", "default_application")
+ environment = kwargs.get("environment", "default_environment")
+ tracer = kwargs.get("tracer")
+ metrics = kwargs.get("metrics_dict")
+ pricing_info = kwargs.get("pricing_info", {})
+ capture_message_content = kwargs.get("capture_message_content", False)
+ disable_metrics = kwargs.get("disable_metrics")
+ detailed_tracing = kwargs.get("detailed_tracing", False)
+
+ # Get version
+ try:
+ version = importlib.metadata.version("agno")
+ except importlib.metadata.PackageNotFoundError:
+ version = "unknown"
+
+ # CRITICAL: Patch ThreadPoolExecutor globally to preserve OpenTelemetry context
+ self._patch_thread_pool_executor()
+
+ # Workflow Operations (Always Instrumented)
+ wrap_function_wrapper(
+ "agno.agent.agent",
+ "Agent.run",
+ agent_run_wrap(
+ "agent.run",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ wrap_function_wrapper(
+ "agno.agent.agent",
+ "Agent.continue_run",
+ agent_continue_run_wrap(
+ "agent.continue_run",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ # CRITICAL: Agent._run_tool is the bridge between agent and tool execution
+ wrap_function_wrapper(
+ "agno.agent.agent",
+ "Agent._run_tool",
+ agent_run_tool_wrap(
+ "agent._run_tool",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ # Async Operations
+ wrap_function_wrapper(
+ "agno.agent.agent",
+ "Agent.arun",
+ async_agent_run_wrap(
+ "agent.arun",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ wrap_function_wrapper(
+ "agno.agent.agent",
+ "Agent.acontinue_run",
+ async_agent_continue_run_wrap(
+ "agent.acontinue_run",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ # Component Operations (Detailed Tracing Only) - Updated to match actual agno structure
+ if detailed_tracing:
+ # CRITICAL: Bridge span context between agent and tool execution
+ wrap_function_wrapper(
+ "agno.models.base",
+ "Model.run_function_call",
+ model_run_function_call_wrap(
+ "model.run_function_call",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ # CRITICAL: Bridge span context for async function calls
+ wrap_function_wrapper(
+ "agno.models.base",
+ "Model.arun_function_call",
+ async_model_run_function_call_wrap(
+ "model.arun_function_call",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ # CRITICAL: Also instrument the batch function calls method
+ wrap_function_wrapper(
+ "agno.models.base",
+ "Model.run_function_calls",
+ model_run_function_call_wrap(
+ "model.run_function_calls",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ wrap_function_wrapper(
+ "agno.models.base",
+ "Model.arun_function_calls",
+ async_model_run_function_call_wrap(
+ "model.arun_function_calls",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ # CRITICAL: Memory operations that bypass model bridge
+ wrap_function_wrapper(
+ "agno.memory.v2.memory",
+ "Memory.add_user_memory",
+ memory_operation_wrap(
+ "memory.add_user_memory",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ wrap_function_wrapper(
+ "agno.memory.v2.memory",
+ "Memory.search_user_memories",
+ memory_operation_wrap(
+ "memory.search_user_memories",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ # Memory Operations (v2)
+ wrap_function_wrapper(
+ "agno.memory.v2.memory",
+ "Memory.add_user_memory",
+ memory_add_wrap(
+ "memory.add_user_memory",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ wrap_function_wrapper(
+ "agno.memory.v2.memory",
+ "Memory.search_user_memories",
+ memory_search_wrap(
+ "memory.search_user_memories",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ # Note: Memory class does not have async_add_user_memory or async_search_user_memories
+
+ # VectorDB Operations (base class)
+ wrap_function_wrapper(
+ "agno.vectordb.base",
+ "VectorDb.search",
+ vectordb_search_wrap(
+ "vectordb.search",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ wrap_function_wrapper(
+ "agno.vectordb.base",
+ "VectorDb.upsert",
+ vectordb_upsert_wrap(
+ "vectordb.upsert",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ # Knowledge Operations
+ wrap_function_wrapper(
+ "agno.knowledge.agent",
+ "AgentKnowledge.search",
+ knowledge_search_wrap(
+ "knowledge.search",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ wrap_function_wrapper(
+ "agno.knowledge.agent",
+ "AgentKnowledge.load",
+ knowledge_add_wrap(
+ "knowledge.load",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ wrap_function_wrapper(
+ "agno.knowledge.agent",
+ "AgentKnowledge.add_document_to_knowledge_base",
+ knowledge_add_wrap(
+ "knowledge.add_document_to_knowledge_base",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ # Workflow Operations
+ wrap_function_wrapper(
+ "agno.workflow.workflow",
+ "Workflow.run",
+ workflow_run_wrap(
+ "workflow.run",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ wrap_function_wrapper(
+ "agno.workflow.workflow",
+ "Workflow.run_workflow",
+ workflow_run_wrap(
+ "workflow.run_workflow",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ # Async Workflow Operations (actual methods that exist)
+ wrap_function_wrapper(
+ "agno.workflow.workflow",
+ "Workflow.arun",
+ async_workflow_run_wrap(
+ "workflow.arun",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ wrap_function_wrapper(
+ "agno.workflow.workflow",
+ "Workflow.arun_workflow",
+ async_workflow_run_wrap(
+ "workflow.arun_workflow",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ # Team Operations
+ wrap_function_wrapper(
+ "agno.team.team",
+ "Team.run",
+ team_run_wrap(
+ "team.run",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ # Team Async Operations (actual methods that exist)
+ wrap_function_wrapper(
+ "agno.team.team",
+ "Team.arun",
+ async_team_run_wrap(
+ "team.arun",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ # Note: VectorDb class does not have async_search or async_upsert methods
+
+ # Note: AgentKnowledge class does not have async_search method
+
+ # Note: AgentKnowledge class does not have async_load or async_add_document_to_knowledge_base methods
+
+ # NOTE: Removed duplicate tool execution instrumentation
+ # The bridge spans from Model.run_function_call provide sufficient tracing
+ # without creating redundant spans for FunctionCall.execute/aexecute
+
+ # Reasoning Operations
+ wrap_function_wrapper(
+ "agno.agent.agent",
+ "Agent.reason",
+ reasoning_wrap(
+ "agent.reason",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ wrap_function_wrapper(
+ "agno.agent.agent",
+ "Agent.areason",
+ async_reasoning_wrap(
+ "agent.areason",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ # Original Component Operations
+ if detailed_tracing:
+ wrap_function_wrapper(
+ "agno.agent.agent",
+ "Agent.add_tool",
+ agent_add_tool_wrap(
+ "agent.add_tool",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ # Note: Agent class does not have async_add_tool method
+
+ wrap_function_wrapper(
+ "agno.agent.agent",
+ "Agent.get_session_summary",
+ session_memory_wrap(
+ "agent.get_session_summary",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ wrap_function_wrapper(
+ "agno.agent.agent",
+ "Agent.get_user_memories",
+ session_memory_wrap(
+ "agent.get_user_memories",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ # Note: Agent class does not have async_get_session_summary or async_get_user_memories methods
+
+ # CRITICAL: Parallel execution operations for context preservation
+ # Note: Parallel class doesn't have a run method, context is preserved via Model.run_function_calls
+
+ wrap_function_wrapper(
+ "agno.team.team",
+ "Team._make_memories_and_summaries",
+ parallel_execution_wrap(
+ "team._make_memories_and_summaries",
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+ ),
+ )
+
+ # NOTE: Removed duplicate reasoning tool instrumentation
+ # The bridge spans from Model.run_function_call provide sufficient tracing
+ # without creating redundant spans for ReasoningTools.think/analyze
+
+ def _patch_thread_pool_executor(self):
+ """
+ CRITICAL: Patch ThreadPoolExecutor.submit globally to preserve OpenTelemetry context.
+ This fixes the broken span hierarchy caused by agno's extensive use of threading.
+ """
+ from concurrent.futures import ThreadPoolExecutor
+ from opentelemetry import context as context_api
+
+ # Store original submit method
+ original_submit = ThreadPoolExecutor.submit
+
+ def context_preserving_submit(self, func, *args, **kwargs):
+ """Submit function while preserving OpenTelemetry context"""
+ # Capture current context
+ current_context = context_api.get_current()
+
+ def context_wrapper(*wrapper_args, **wrapper_kwargs):
+ # Restore context in the thread
+ token = context_api.attach(current_context)
+ try:
+ return func(*wrapper_args, **wrapper_kwargs)
+ finally:
+ context_api.detach(token)
+
+ return original_submit(self, context_wrapper, *args, **kwargs)
+
+ # Apply the patch
+ ThreadPoolExecutor.submit = context_preserving_submit
+
+ # Store original for potential uninstrumentation
+ self._original_thread_pool_submit = original_submit
+
+ def _uninstrument(self, **kwargs):
+ # Restore original ThreadPoolExecutor.submit if it was patched
+ if hasattr(self, "_original_thread_pool_submit"):
+ from concurrent.futures import ThreadPoolExecutor
+
+ ThreadPoolExecutor.submit = self._original_thread_pool_submit
diff --git a/sdk/python/src/openlit/instrumentation/agno/agno.py b/sdk/python/src/openlit/instrumentation/agno/agno.py
new file mode 100644
index 00000000..12d8e288
--- /dev/null
+++ b/sdk/python/src/openlit/instrumentation/agno/agno.py
@@ -0,0 +1,1358 @@
+"""
+Module for monitoring Agno agent framework operations.
+"""
+
+import logging
+import time
+from opentelemetry.trace import Status, StatusCode, SpanKind
+from opentelemetry import context as context_api
+from openlit.__helpers import (
+ handle_exception,
+)
+from openlit.instrumentation.agno.utils import (
+ process_agent_request,
+ process_tool_request,
+ process_memory_request,
+ process_reasoning_request,
+ process_vectordb_request,
+ process_knowledge_request,
+ process_workflow_request,
+ process_team_request,
+)
+from openlit.semcov import SemanticConvention
+
+# Initialize logger for Agno monitoring
+logger = logging.getLogger(__name__)
+
+
+def agent_run_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Agent.run method with comprehensive instrumentation using process functions only.
+ """
+
+ def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return wrapped(*args, **kwargs)
+
+ # Extract agent name for span naming with fallback to agent_id
+ agent_name = (
+ getattr(instance, "name", None)
+ or getattr(instance, "agent_id", None)
+ or "default_agent"
+ )
+ span_name = f"agent {agent_name}"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
+ start_time = time.time()
+ response = wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_agent_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ response,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT,
+ )
+
+ # Mark span as successful
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ # Handle instrumentation exceptions - log but don't raise
+ handle_exception(span, e)
+ logger.error("Error in agent.run trace creation: %s", e)
+
+ return response
+
+ return wrapper
+
+
+def agent_run_tool_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Agent._run_tool method - the critical bridge between agent and tool execution.
+ This method runs within the agent context and coordinates tool execution.
+ """
+
+ def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return wrapped(*args, **kwargs)
+
+ # Extract tool information for span naming
+ tool = args[1] if len(args) > 1 else None # tool: ToolExecution
+ tool_name = "unknown_tool"
+ if tool and hasattr(tool, "name"):
+ tool_name = tool.name
+ elif tool and hasattr(tool, "function") and hasattr(tool.function, "name"):
+ tool_name = tool.function.name
+
+ span_name = f"agent run tool {tool_name}"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.INTERNAL) as span:
+ start_time = time.time()
+ result = wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_tool_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ tool_name,
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in agent._run_tool trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+def agent_continue_run_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Agent.continue_run method.
+ """
+
+ def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return wrapped(*args, **kwargs)
+
+ agent_name = getattr(instance, "name", "unknown")
+ span_name = f"continue {agent_name}"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
+ start_time = time.time()
+ result = wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_agent_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT,
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in agent.continue_run trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+def agent_add_tool_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Agent.add_tool method for detailed tracing.
+ """
+
+ def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return wrapped(*args, **kwargs)
+
+ agent_name = getattr(instance, "name", "unknown")
+ span_name = f"agent {agent_name}"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.INTERNAL) as span:
+ start_time = time.time()
+ result = wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_tool_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_TOOLS,
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in agent.add_tool trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+def session_memory_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Agent memory operations (get_session_summary, get_user_memories).
+ """
+
+ def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return wrapped(*args, **kwargs)
+
+ # Extract method name from endpoint
+ method_name = gen_ai_endpoint.split(".")[-1]
+ span_name = f"memory {method_name.replace('get_', '').replace('_', ' ')}"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.INTERNAL) as span:
+ # Execute memory operation with timing
+ start_time = time.time()
+ result = wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ # Extract method name for operation type
+ operation_type = method_name.replace("get_", "").replace("_", " ")
+ process_memory_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ operation_type,
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in memory operation trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+def model_run_function_call_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Model.run_function_call method to bridge agent and tool span context.
+ This is the critical method that connects agent execution to tool execution.
+ """
+
+ def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return wrapped(*args, **kwargs)
+
+ # Extract function call information for span naming
+ function_call = args[0] if args else kwargs.get("function_call", None)
+ function_name = None
+
+ if function_call:
+ # Extract function name from the FunctionCall object
+ if hasattr(function_call, "function") and hasattr(
+ function_call.function, "name"
+ ):
+ function_name = function_call.function.name
+ elif hasattr(function_call, "name"):
+ function_name = function_call.name
+
+ # Skip creating span if we can't identify the function
+ if not function_name or function_name == "unknown_function":
+ return wrapped(*args, **kwargs)
+
+ span_name = f"tool {function_name}"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.INTERNAL) as span:
+ start_time = time.time()
+ result = wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_tool_request(
+ span,
+ function_call,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ function_name,
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in model.run_function_call trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+# Tools Component Wrappers
+def function_call_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Function call method for tool execution tracing.
+ """
+
+ def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return wrapped(*args, **kwargs)
+
+ # Extract function information
+ function_name = getattr(
+ instance, "name", getattr(instance, "__name__", "unknown_function")
+ )
+ span_name = f"tool {function_name}"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.INTERNAL) as span:
+ # Execute function with timing
+ start_time = time.time()
+ result = wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_tool_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_TOOLS,
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in tool execution trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+def toolkit_run_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Toolkit run method for toolkit execution tracing.
+ """
+
+ def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return wrapped(*args, **kwargs)
+
+ # Extract toolkit information
+ toolkit_name = getattr(
+ instance,
+ "name",
+ getattr(instance, "__class__", {}).get("__name__", "unknown_toolkit"),
+ )
+ span_name = f"toolkit {toolkit_name}"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.INTERNAL) as span:
+ # Execute toolkit with timing
+ start_time = time.time()
+ result = wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_tool_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_TOOLS,
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in toolkit execution trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+def function_entrypoint_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Function.entrypoint method to catch direct tool executions that bypass Model.run_function_call.
+ This ensures ALL tool executions maintain span context.
+ """
+
+ def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return wrapped(*args, **kwargs)
+
+ # Extract function information for span naming
+ function_name = getattr(instance, "name", None) or getattr(
+ instance, "__name__", "unknown_function"
+ )
+ span_name = f"tool {function_name}"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.INTERNAL) as span:
+ start_time = time.time()
+ result = wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_tool_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ function_name,
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in function.entrypoint trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+# Tool Execution Component Wrappers
+def function_execute_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno FunctionCall.execute method for tool execution tracing using process functions only.
+ """
+
+ def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return wrapped(*args, **kwargs)
+
+ # Extract function information
+ function_name = getattr(instance.function, "name", "unknown_function")
+ span_name = f"tool {function_name}"
+
+ # CRITICAL: Capture current OpenTelemetry context to ensure proper nesting
+ current_context = context_api.get_current()
+
+ with tracer.start_as_current_span(
+ span_name, kind=SpanKind.INTERNAL, context=current_context
+ ) as span:
+ # Execute tool with timing
+ start_time = time.time()
+ # CRITICAL: Set the span context as current for nested calls
+ token = context_api.attach(
+ context_api.set_value("current_span", span, current_context)
+ )
+ try:
+ result = wrapped(*args, **kwargs)
+ finally:
+ context_api.detach(token)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_tool_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ function_name,
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in tool execution trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+def parallel_execution_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap parallel execution methods to preserve OpenTelemetry context through ThreadPoolExecutor.
+ This is critical for maintaining span hierarchy in parallel workflows and team operations.
+ """
+ from concurrent.futures import ThreadPoolExecutor
+
+ def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return wrapped(*args, **kwargs)
+
+ # Capture current OpenTelemetry context
+ current_context = context_api.get_current()
+
+ # Patch ThreadPoolExecutor.submit to preserve context
+ original_submit = ThreadPoolExecutor.submit
+
+ def context_preserving_submit(
+ executor_self, func, *submit_args, **submit_kwargs
+ ):
+ """Submit function to executor while preserving OpenTelemetry context"""
+
+ def context_wrapper(*wrapper_args, **wrapper_kwargs):
+ # Restore the OpenTelemetry context in the thread
+ token = context_api.attach(current_context)
+ try:
+ return func(*wrapper_args, **wrapper_kwargs)
+ finally:
+ context_api.detach(token)
+
+ return original_submit(
+ executor_self, context_wrapper, *submit_args, **submit_kwargs
+ )
+
+ # Temporarily patch the submit method
+ ThreadPoolExecutor.submit = context_preserving_submit
+
+ try:
+ result = wrapped(*args, **kwargs)
+ finally:
+ # Restore original submit method
+ ThreadPoolExecutor.submit = original_submit
+
+ return result
+
+ return wrapper
+
+
+def reasoning_tool_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap reasoning tools (think, analyze) to maintain proper span hierarchy.
+ These tools were previously creating disconnected spans.
+ """
+
+ def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return wrapped(*args, **kwargs)
+
+ # Extract tool name from endpoint
+ tool_name = gen_ai_endpoint.split(".")[-1]
+ span_name = f"reasoning {tool_name}"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.INTERNAL) as span:
+ start_time = time.time()
+ result = wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_reasoning_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ tool_name,
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in reasoning tool trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+# Reasoning Component Wrappers
+def reasoning_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Agent.reason method for reasoning operation tracing.
+ """
+
+ def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return wrapped(*args, **kwargs)
+
+ agent_name = getattr(instance, "name", "unknown_agent")
+ span_name = f"reasoning {agent_name}"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.INTERNAL) as span:
+ # Execute reasoning with timing
+ start_time = time.time()
+ result = wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ # Use reasoning operation for reasoning requests
+ process_reasoning_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ "reasoning",
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in reasoning trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+def memory_operation_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Memory operations that bypass Model.run_function_call to maintain span context.
+ """
+
+ def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return wrapped(*args, **kwargs)
+
+ # Extract operation name from endpoint
+ operation_name = gen_ai_endpoint.split(".")[-1]
+ span_name = f"memory {operation_name.replace('_', ' ')}"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.INTERNAL) as span:
+ start_time = time.time()
+ result = wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_memory_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ operation_name.replace("_", " "),
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in memory operation trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+# Memory Component Wrappers
+def memory_add_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Memory add method for memory storage tracing using process functions only.
+ """
+
+ def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return wrapped(*args, **kwargs)
+
+ span_name = "memory add"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.INTERNAL) as span:
+ # Execute memory operation with timing
+ start_time = time.time()
+ result = wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_memory_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ "add",
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in memory add trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+def memory_search_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Memory search method for memory retrieval tracing using process functions only.
+ """
+
+ def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return wrapped(*args, **kwargs)
+
+ span_name = "memory search"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.INTERNAL) as span:
+ # Execute memory search with timing
+ start_time = time.time()
+ result = wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_memory_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ "search",
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in memory search trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+# VectorDB Component Wrappers
+def vectordb_search_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno VectorDb search method for vector search tracing using process functions only.
+ """
+
+ def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return wrapped(*args, **kwargs)
+
+ span_name = "vectordb search"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
+ # Execute vectordb search with timing
+ start_time = time.time()
+ result = wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_vectordb_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ "search",
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in vectordb search trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+def vectordb_upsert_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno VectorDb upsert method for vector upsert tracing using process functions only.
+ """
+
+ def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return wrapped(*args, **kwargs)
+
+ span_name = "vectordb upsert"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
+ # Execute vectordb upsert with timing
+ start_time = time.time()
+ result = wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_vectordb_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ "upsert",
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in vectordb upsert trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+# Knowledge Component Wrappers
+def knowledge_search_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno AgentKnowledge search method for knowledge search tracing using process functions only.
+ """
+
+ def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return wrapped(*args, **kwargs)
+
+ span_name = "knowledge search"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.INTERNAL) as span:
+ # Execute knowledge search with timing
+ start_time = time.time()
+ result = wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_knowledge_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ "search",
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in knowledge search trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+def knowledge_add_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno AgentKnowledge add method for knowledge addition tracing using process functions only.
+ """
+
+ def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return wrapped(*args, **kwargs)
+
+ span_name = "knowledge add"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.INTERNAL) as span:
+ # Execute knowledge addition with timing
+ start_time = time.time()
+ result = wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_knowledge_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ "add",
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in knowledge add trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+# Workflow Component Wrappers
+def workflow_run_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Workflow run method for workflow execution tracing using process functions only.
+ """
+
+ def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return wrapped(*args, **kwargs)
+
+ workflow_name = getattr(instance, "name", "unknown_workflow")
+ span_name = f"workflow {workflow_name}"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
+ # Execute workflow with timing
+ start_time = time.time()
+ result = wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_workflow_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in workflow run trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+# Team Component Wrappers
+def team_run_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Team run method for team execution tracing.
+ """
+
+ def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return wrapped(*args, **kwargs)
+
+ team_name = getattr(instance, "name", "unknown_team")
+ span_name = f"team {team_name}"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
+ # Execute team with timing
+ start_time = time.time()
+ result = wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_team_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in team run trace creation: %s", e)
+
+ return result
+
+ return wrapper
diff --git a/sdk/python/src/openlit/instrumentation/agno/async_agno.py b/sdk/python/src/openlit/instrumentation/agno/async_agno.py
new file mode 100644
index 00000000..21906140
--- /dev/null
+++ b/sdk/python/src/openlit/instrumentation/agno/async_agno.py
@@ -0,0 +1,1127 @@
+"""
+Module for monitoring Agno agent framework async operations.
+"""
+
+import logging
+import time
+from opentelemetry.trace import Status, StatusCode, SpanKind
+from opentelemetry import context as context_api
+from openlit.__helpers import (
+ handle_exception,
+)
+from openlit.instrumentation.agno.utils import (
+ process_agent_request,
+ process_tool_request,
+ process_memory_request,
+ process_reasoning_request,
+ process_vectordb_request,
+ process_knowledge_request,
+ process_workflow_request,
+ process_team_request,
+)
+from openlit.semcov import SemanticConvention
+
+# Initialize logger for Agno async monitoring
+logger = logging.getLogger(__name__)
+
+
+def async_agent_run_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Agent.arun method with comprehensive async instrumentation using process functions only.
+ """
+
+ async def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return await wrapped(*args, **kwargs)
+
+ # Extract agent name for span naming with fallback to agent_id
+ agent_name = (
+ getattr(instance, "name", None)
+ or getattr(instance, "agent_id", None)
+ or "default_agent"
+ )
+ span_name = f"agent {agent_name}"
+
+ # CRITICAL: Capture current OpenTelemetry context to ensure proper nesting
+ current_context = context_api.get_current()
+
+ with tracer.start_as_current_span(
+ span_name, kind=SpanKind.CLIENT, context=current_context
+ ) as span:
+ start_time = time.time()
+ # CRITICAL: Set the span context as current for nested calls
+ with context_api.attach(
+ context_api.set_value("current_span", span, current_context)
+ ):
+ response = await wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_agent_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ response,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT,
+ )
+
+ # Mark span as successful
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ # Handle instrumentation exceptions - log but don't raise
+ handle_exception(span, e)
+ logger.error("Error in async agent.arun trace creation: %s", e)
+
+ return response
+
+ return wrapper
+
+
+def async_agent_continue_run_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Agent.acontinue_run method using process functions only.
+ """
+
+ async def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return await wrapped(*args, **kwargs)
+
+ agent_name = getattr(instance, "name", "unknown")
+ span_name = f"continue {agent_name}"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
+ start_time = time.time()
+ result = await wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_agent_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT,
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in async agent.acontinue_run trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+def async_model_run_function_call_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Model.arun_function_call async method to bridge agent and tool span context.
+ This is the critical method that connects agent execution to tool execution.
+ """
+
+ async def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return await wrapped(*args, **kwargs)
+
+ # Extract function call information for span naming
+ function_call = args[0] if args else None
+ function_name = "unknown_function"
+ if function_call and hasattr(function_call, "function"):
+ if hasattr(function_call.function, "name"):
+ function_name = function_call.function.name
+ elif hasattr(function_call.function, "__name__"):
+ function_name = function_call.function.__name__
+
+ span_name = f"model run function {function_name}"
+
+ # CRITICAL: Capture current OpenTelemetry context to ensure proper nesting
+ current_context = context_api.get_current()
+
+ with tracer.start_as_current_span(
+ span_name, kind=SpanKind.INTERNAL, context=current_context
+ ) as span:
+ start_time = time.time()
+ # CRITICAL: Set the span context as current for nested calls
+ with context_api.attach(
+ context_api.set_value("current_span", span, current_context)
+ ):
+ result = await wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_tool_request(
+ span,
+ function_call,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ function_name,
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error(
+ "Error in async model.arun_function_call trace creation: %s", e
+ )
+
+ return result
+
+ return wrapper
+
+
+def async_function_entrypoint_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Function.entrypoint async method to catch direct async tool executions.
+ """
+
+ async def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return await wrapped(*args, **kwargs)
+
+ # Extract function information for span naming
+ function_name = getattr(instance, "name", None) or getattr(
+ instance, "__name__", "unknown_function"
+ )
+ span_name = f"tool {function_name}"
+
+ # CRITICAL: Capture current OpenTelemetry context to ensure proper nesting
+ current_context = context_api.get_current()
+
+ with tracer.start_as_current_span(
+ span_name, kind=SpanKind.INTERNAL, context=current_context
+ ) as span:
+ start_time = time.time()
+ # CRITICAL: Set the span context as current for nested calls
+ with context_api.attach(
+ context_api.set_value("current_span", span, current_context)
+ ):
+ result = await wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_tool_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ function_name,
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in async function.entrypoint trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+# Async Tools Component Wrappers
+def async_function_call_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Function async call method for tool execution tracing using process functions only.
+ """
+
+ async def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return await wrapped(*args, **kwargs)
+
+ # Extract function information
+ function_name = getattr(
+ instance, "name", getattr(instance, "__name__", "unknown_function")
+ )
+ span_name = f"tool {function_name}"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.INTERNAL) as span:
+ # Execute async function with timing
+ start_time = time.time()
+ result = await wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_tool_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_TOOLS,
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in async tool execution trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+# Async Memory Component Wrappers
+def async_memory_add_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Memory async add method for memory storage tracing using process functions only.
+ """
+
+ async def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return await wrapped(*args, **kwargs)
+
+ span_name = "memory add"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.INTERNAL) as span:
+ start_time = time.time()
+ result = await wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_memory_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_MEMORY,
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in async memory add trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+def async_memory_search_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Memory async search method for memory retrieval tracing using process functions only.
+ """
+
+ async def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return await wrapped(*args, **kwargs)
+
+ span_name = "memory search"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.INTERNAL) as span:
+ start_time = time.time()
+ result = await wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_memory_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_MEMORY,
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in async memory search trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+# Async VectorDB Component Wrappers
+def async_vectordb_search_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno VectorDb async search method for vector search tracing using process functions only.
+ """
+
+ async def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return await wrapped(*args, **kwargs)
+
+ span_name = "vectordb search"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
+ start_time = time.time()
+ result = await wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_vectordb_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_VECTORDB,
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in async vectordb search trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+# Async Knowledge Component Wrappers
+def async_knowledge_search_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno AgentKnowledge async search method for knowledge search tracing using process functions only.
+ """
+
+ async def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return await wrapped(*args, **kwargs)
+
+ span_name = "knowledge search"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.INTERNAL) as span:
+ start_time = time.time()
+ result = await wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_knowledge_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_KNOWLEDGE,
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in async knowledge search trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+# Async Workflow Component Wrappers
+def async_workflow_run_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Workflow async run method for workflow execution tracing using process functions only.
+ """
+
+ async def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return await wrapped(*args, **kwargs)
+
+ workflow_name = getattr(instance, "name", "unknown_workflow")
+ span_name = f"workflow {workflow_name}"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
+ start_time = time.time()
+ result = await wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_workflow_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_WORKFLOW,
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in async workflow run trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+# Async Team Component Wrappers
+def async_team_run_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Team async run method for team execution tracing using process functions only.
+ """
+
+ async def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return await wrapped(*args, **kwargs)
+
+ team_name = getattr(instance, "name", "unknown_team")
+ span_name = f"team {team_name}"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
+ start_time = time.time()
+ result = await wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_team_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_TEAM,
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in async team run trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+def async_agent_add_tool_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Agent.add_tool method for detailed async tracing using process functions only.
+ """
+
+ async def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return await wrapped(*args, **kwargs)
+
+ agent_name = getattr(instance, "name", "unknown")
+ span_name = f"agent {agent_name}"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.INTERNAL) as span:
+ start_time = time.time()
+ result = await wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_tool_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_TOOLS,
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in async agent.add_tool trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+def async_session_memory_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Agent async memory operations (get_session_summary, get_user_memories) using process functions only.
+ """
+
+ async def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return await wrapped(*args, **kwargs)
+
+ # Extract method name from endpoint
+ method_name = gen_ai_endpoint.split(".")[-1]
+ span_name = f"memory {method_name.replace('get_', '').replace('_', ' ')}"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.INTERNAL) as span:
+ # Execute async memory operation with timing
+ start_time = time.time()
+ result = await wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ # Extract method name for operation type
+ operation_type = method_name.replace("get_", "").replace("_", " ")
+ process_memory_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ operation_type,
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in async memory operation trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+def async_function_execute_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno FunctionCall.aexecute method for async tool execution tracing using process functions only.
+ """
+
+ async def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return await wrapped(*args, **kwargs)
+
+ # Extract function information
+ function_name = getattr(instance.function, "name", "unknown_function")
+ span_name = f"tool {function_name}"
+
+ # CRITICAL: Capture current OpenTelemetry context to ensure proper nesting
+ current_context = context_api.get_current()
+
+ with tracer.start_as_current_span(
+ span_name, kind=SpanKind.INTERNAL, context=current_context
+ ) as span:
+ # Execute async tool with timing
+ start_time = time.time()
+ # CRITICAL: Set the span context as current for nested calls
+ with context_api.attach(
+ context_api.set_value("current_span", span, current_context)
+ ):
+ result = await wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_tool_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_TOOLS,
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in async tool execution trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+def async_toolkit_run_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Toolkit async run method for toolkit execution tracing using process functions only.
+ """
+
+ async def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return await wrapped(*args, **kwargs)
+
+ # Extract toolkit information
+ toolkit_name = getattr(
+ instance,
+ "name",
+ getattr(instance, "__class__", {}).get("__name__", "unknown_toolkit"),
+ )
+ span_name = f"toolkit {toolkit_name}"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.INTERNAL) as span:
+ # Execute async toolkit with timing
+ start_time = time.time()
+ result = await wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_tool_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_TOOLS,
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in async toolkit execution trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+def async_reasoning_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno Agent.areason method for async reasoning operation tracing using process functions only.
+ """
+
+ async def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return await wrapped(*args, **kwargs)
+
+ agent_name = getattr(instance, "name", "unknown_agent")
+ span_name = f"reasoning {agent_name}"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.INTERNAL) as span:
+ # Execute async reasoning with timing
+ start_time = time.time()
+ result = await wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_reasoning_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ "reasoning",
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in async reasoning trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+def async_vectordb_upsert_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno VectorDb async upsert method for vector upsert tracing using process functions only.
+ """
+
+ async def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return await wrapped(*args, **kwargs)
+
+ span_name = "vectordb upsert"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.CLIENT) as span:
+ # Execute async vectordb upsert with timing
+ start_time = time.time()
+ result = await wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_vectordb_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ "upsert",
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in async vectordb upsert trace creation: %s", e)
+
+ return result
+
+ return wrapper
+
+
+def async_knowledge_add_wrap(
+ gen_ai_endpoint,
+ version,
+ environment,
+ application_name,
+ tracer,
+ pricing_info,
+ capture_message_content,
+ metrics,
+ disable_metrics,
+):
+ """
+ Wrap Agno AgentKnowledge async add method for knowledge addition tracing using process functions only.
+ """
+
+ async def wrapper(wrapped, instance, args, kwargs):
+ # CRITICAL: Suppression check to prevent recursive instrumentation
+ if context_api.get_value(context_api._SUPPRESS_INSTRUMENTATION_KEY):
+ return await wrapped(*args, **kwargs)
+
+ span_name = "knowledge add"
+
+ with tracer.start_as_current_span(span_name, kind=SpanKind.INTERNAL) as span:
+ # Execute async knowledge addition with timing
+ start_time = time.time()
+ result = await wrapped(*args, **kwargs)
+
+ try:
+ # Process request using utils function with ALL attributes from semcov
+ process_knowledge_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ result,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ "add",
+ )
+
+ span.set_status(Status(StatusCode.OK))
+
+ except Exception as e:
+ handle_exception(span, e)
+ logger.error("Error in async knowledge add trace creation: %s", e)
+
+ return result
+
+ return wrapper
diff --git a/sdk/python/src/openlit/instrumentation/agno/utils.py b/sdk/python/src/openlit/instrumentation/agno/utils.py
new file mode 100644
index 00000000..9d18c246
--- /dev/null
+++ b/sdk/python/src/openlit/instrumentation/agno/utils.py
@@ -0,0 +1,767 @@
+"""
+Utility functions for Agno instrumentation following OpenLIT patterns.
+"""
+
+import logging
+import time
+from openlit.__helpers import (
+ common_span_attributes,
+)
+from openlit.semcov import SemanticConvention
+
+# Initialize logger
+logger = logging.getLogger(__name__)
+
+
+# Simple utility functions following OpenLIT patterns
+
+
+class _ScopeWrapper:
+ """
+ A scope wrapper class for common_span_attributes compatibility.
+
+ This class wraps the necessary parameters required by the common_span_attributes
+ function to maintain consistency with OpenLIT instrumentation patterns.
+ """
+
+ def __init__(self, span, instance, kwargs, args, start_time):
+ """Initialize the scope wrapper with required parameters."""
+ self._span = span
+ self._instance = instance
+ self._kwargs = kwargs
+ self._args = args
+ self._start_time = start_time
+ self._end_time = time.time()
+
+ def get_span(self):
+ """Get the associated span."""
+ return self._span
+
+ def get_instance(self):
+ """Get the instrumented instance."""
+ return self._instance
+
+
+def process_agent_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ response,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ operation_type=SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT,
+):
+ """
+ Process agent request and generate ALL telemetry attributes from semcov (CrewAI pattern)
+ """
+
+ # Calculate execution time
+ execution_time = time.time() - start_time
+
+ # Extract agent information
+ agent_name = (
+ getattr(instance, "name", None)
+ or getattr(instance, "agent_id", None)
+ or "default_agent"
+ )
+ request_model = None
+
+ # Get model information
+ if hasattr(instance, "model"):
+ model = instance.model
+ if hasattr(model, "id"):
+ request_model = str(model.id)
+ elif hasattr(model, "name"):
+ request_model = str(model.name)
+
+ # Create scope object for common_span_attributes compatibility
+ scope = _ScopeWrapper(span, instance, kwargs, args, start_time)
+
+ # Use common span attributes helper from __helpers
+ common_span_attributes(
+ scope,
+ operation_type,
+ SemanticConvention.GEN_AI_SYSTEM_AGNO,
+ "localhost", # server_address
+ 80, # server_port
+ request_model,
+ request_model, # response_model same as request
+ environment,
+ application_name,
+ kwargs.get("stream", False), # is_stream
+ 0, # tbt
+ 0, # ttft
+ version,
+ )
+
+ # Set agno-specific attributes using semantic conventions
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_NAME, agent_name)
+
+ # Set lifecycle phase based on operation
+ if operation_type == SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT:
+ span.set_attribute(
+ SemanticConvention.GEN_AI_AGENT_LIFECYCLE_PHASE,
+ SemanticConvention.GEN_AI_AGENT_LIFECYCLE_PHASE_EXECUTE,
+ )
+ elif operation_type == SemanticConvention.GEN_AI_OPERATION_TYPE_MEMORY:
+ span.set_attribute(
+ SemanticConvention.GEN_AI_AGENT_LIFECYCLE_PHASE,
+ SemanticConvention.GEN_AI_AGENT_LIFECYCLE_PHASE_EXECUTE,
+ )
+ elif operation_type == SemanticConvention.GEN_AI_OPERATION_TYPE_TOOLS:
+ span.set_attribute(
+ SemanticConvention.GEN_AI_AGENT_LIFECYCLE_PHASE,
+ SemanticConvention.GEN_AI_AGENT_LIFECYCLE_PHASE_TOOL_EXECUTION,
+ )
+
+ # Add detailed agent information if available
+ if hasattr(instance, "instructions") and instance.instructions:
+ span.set_attribute(
+ SemanticConvention.GEN_AI_AGENT_INSTRUCTIONS,
+ str(instance.instructions)[:500],
+ )
+
+ if hasattr(instance, "agent_id") and instance.agent_id:
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_ID, instance.agent_id)
+
+ if hasattr(instance, "description") and instance.description:
+ span.set_attribute(
+ SemanticConvention.GEN_AI_AGENT_DESCRIPTION, str(instance.description)[:500]
+ )
+
+ if hasattr(instance, "introduction") and instance.introduction:
+ span.set_attribute(
+ SemanticConvention.GEN_AI_AGENT_INTRODUCTION,
+ str(instance.introduction)[:500],
+ )
+
+ # Add request-specific attributes from args and kwargs
+ if args and args[0]:
+ if capture_message_content:
+ span.set_attribute(
+ SemanticConvention.GEN_AI_CONTENT_PROMPT, str(args[0])[:1000]
+ )
+
+ # User and session information
+ if "user_id" in kwargs and kwargs["user_id"]:
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER, kwargs["user_id"])
+ elif hasattr(instance, "user_id") and instance.user_id:
+ span.set_attribute(SemanticConvention.GEN_AI_REQUEST_USER, instance.user_id)
+
+ if "session_id" in kwargs and kwargs["session_id"]:
+ span.set_attribute(SemanticConvention.GEN_AI_SESSION_ID, kwargs["session_id"])
+
+ # Stream and reasoning attributes
+ if "stream" in kwargs:
+ span.set_attribute(
+ SemanticConvention.GEN_AI_REQUEST_IS_STREAM, bool(kwargs["stream"])
+ )
+
+ if "show_full_reasoning" in kwargs:
+ span.set_attribute(
+ SemanticConvention.GEN_AI_AGENT_SHOW_REASONING,
+ bool(kwargs["show_full_reasoning"]),
+ )
+
+ if "stream_intermediate_steps" in kwargs:
+ span.set_attribute(
+ SemanticConvention.GEN_AI_AGENT_STREAM_INTERMEDIATE_STEPS,
+ bool(kwargs["stream_intermediate_steps"]),
+ )
+
+ # Set execution time using semantic convention
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_EXECUTION_TIME, execution_time)
+
+ # Process response with comprehensive output capture
+ if response:
+ if capture_message_content:
+ if hasattr(response, "content") and response.content:
+ content = str(response.content)[:2000]
+ span.set_attribute(
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION, content
+ )
+ elif hasattr(response, "message") and response.message:
+ content = str(response.message)[:2000]
+ span.set_attribute(
+ SemanticConvention.GEN_AI_CONTENT_COMPLETION, content
+ )
+
+ # Capture additional response metadata
+ if hasattr(response, "metrics"):
+ span.set_attribute(
+ SemanticConvention.GEN_AI_AGENT_RESPONSE_TIME, execution_time
+ )
+
+
+def process_tool_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ response,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ tool_name,
+):
+ """
+ Process tool execution request and generate ALL telemetry attributes from semcov
+ """
+
+ execution_time = time.time() - start_time
+
+ # Create scope object for common_span_attributes compatibility
+ scope = _ScopeWrapper(span, instance, kwargs, args, start_time)
+
+ # Get model info from instance if available
+ request_model = getattr(instance, "model", None)
+ if request_model and hasattr(request_model, "id"):
+ model_name = request_model.id
+ else:
+ model_name = "unknown"
+
+ # Use common span attributes for tool operations
+ common_span_attributes(
+ scope,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_EXECUTE_AGENT_TASK,
+ SemanticConvention.GEN_AI_SYSTEM_AGNO,
+ "localhost", # server_address
+ 80, # server_port
+ model_name, # request_model
+ model_name, # response_model
+ environment,
+ application_name,
+ False, # is_stream
+ 0, # tbt
+ 0, # ttft
+ version,
+ )
+
+ # Set tool-specific attributes using semcov
+ span.set_attribute(SemanticConvention.GEN_AI_TOOL_NAME, tool_name)
+ span.set_attribute(
+ SemanticConvention.GEN_AI_AGENT_LIFECYCLE_PHASE,
+ SemanticConvention.GEN_AI_AGENT_LIFECYCLE_PHASE_TOOL_EXECUTION,
+ )
+
+ # Set tool-specific attributes that aren't in the process function
+ if (
+ hasattr(instance, "function")
+ and hasattr(instance.function, "description")
+ and instance.function.description
+ ):
+ span.set_attribute(
+ SemanticConvention.GEN_AI_TOOL_DESCRIPTION,
+ str(instance.function.description)[:500],
+ )
+
+ if hasattr(instance, "arguments") and instance.arguments:
+ span.set_attribute(
+ SemanticConvention.GEN_AI_TOOL_PARAMETERS, str(instance.arguments)[:1000]
+ )
+
+ # Set execution metrics
+ span.set_attribute(
+ SemanticConvention.GEN_AI_TOOL_EXECUTION_DURATION, execution_time
+ )
+
+ # Process result
+ if response and hasattr(response, "status"):
+ span.set_attribute(
+ SemanticConvention.GEN_AI_TOOL_EXECUTION_SUCCESS,
+ response.status == "success",
+ )
+ if capture_message_content:
+ if hasattr(response, "result") and response.result:
+ span.set_attribute(
+ SemanticConvention.GEN_AI_TOOL_OUTPUT, str(response.result)[:1000]
+ )
+ if hasattr(response, "error") and response.error:
+ span.set_attribute(
+ SemanticConvention.GEN_AI_TOOL_ERROR, str(response.error)[:500]
+ )
+
+
+def process_memory_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ response,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ memory_operation,
+):
+ """
+ Process memory operation request and generate ALL telemetry attributes from semcov
+ """
+
+ execution_time = time.time() - start_time
+
+ # Create scope object for common_span_attributes compatibility
+ scope = _ScopeWrapper(span, instance, kwargs, args, start_time)
+
+ # Use common span attributes for memory operations
+ common_span_attributes(
+ scope,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_MEMORY,
+ SemanticConvention.GEN_AI_SYSTEM_AGNO,
+ "localhost", # server_address
+ 80, # server_port
+ None, # request_model
+ None, # response_model
+ environment,
+ application_name,
+ False, # is_stream
+ 0, # tbt
+ 0, # ttft
+ version,
+ )
+
+ # Set memory-specific attributes using semcov
+ span.set_attribute(SemanticConvention.GEN_AI_MEMORY_OPERATION, memory_operation)
+ span.set_attribute(
+ SemanticConvention.GEN_AI_AGENT_LIFECYCLE_PHASE,
+ SemanticConvention.GEN_AI_AGENT_LIFECYCLE_PHASE_EXECUTE,
+ )
+
+ # Set memory-specific attributes that aren't in the process function
+ if hasattr(instance, "db") and instance.db:
+ span.set_attribute("gen_ai.memory.db_type", type(instance.db).__name__)
+
+ if hasattr(instance, "table_name"):
+ span.set_attribute("gen_ai.memory.table_name", str(instance.table_name))
+
+ # Add input data
+ if args and capture_message_content:
+ span.set_attribute(
+ "gen_ai.memory.input", str(args[0])[:1000] if args[0] else ""
+ )
+
+ # Add metadata from kwargs
+ if "user_id" in kwargs:
+ span.set_attribute("gen_ai.memory.user_id", kwargs["user_id"])
+ if "agent_id" in kwargs:
+ span.set_attribute("gen_ai.memory.agent_id", kwargs["agent_id"])
+ if "metadata" in kwargs:
+ span.set_attribute("gen_ai.memory.metadata", str(kwargs["metadata"])[:500])
+
+ # Set execution metrics
+ span.set_attribute("gen_ai.memory.operation.duration", execution_time)
+
+ # Process result
+ if response:
+ if hasattr(response, "id"):
+ span.set_attribute("gen_ai.memory.result_id", str(response.id))
+ span.set_attribute("gen_ai.memory.operation.success", True)
+ else:
+ span.set_attribute("gen_ai.memory.operation.success", False)
+
+
+def process_reasoning_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ response,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ operation_type,
+):
+ """
+ Process reasoning operation request and generate ALL telemetry attributes from semcov
+ """
+
+ execution_time = time.time() - start_time
+ agent_name = getattr(instance, "name", None) or "unknown_agent"
+
+ # Create scope object for common_span_attributes compatibility
+ scope = _ScopeWrapper(span, instance, kwargs, args, start_time)
+
+ # Get model info from agent instance if available
+ request_model = getattr(instance, "model", None)
+ if request_model and hasattr(request_model, "id"):
+ model_name = request_model.id
+ else:
+ model_name = "unknown"
+
+ # Use common span attributes for reasoning operations (use agent task operation type)
+ common_span_attributes(
+ scope,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_EXECUTE_AGENT_TASK,
+ SemanticConvention.GEN_AI_SYSTEM_AGNO,
+ "localhost", # server_address
+ 80, # server_port
+ model_name, # request_model
+ model_name, # response_model
+ environment,
+ application_name,
+ False, # is_stream
+ 0, # tbt
+ 0, # ttft
+ version,
+ )
+
+ # Set reasoning-specific attributes using semcov
+ span.set_attribute(
+ SemanticConvention.GEN_AI_AGENT_LIFECYCLE_PHASE,
+ SemanticConvention.GEN_AI_AGENT_LIFECYCLE_PHASE_EXECUTE,
+ )
+ span.set_attribute(SemanticConvention.GEN_AI_AGENT_NAME, agent_name)
+
+ # Add reasoning-specific attributes
+ if hasattr(instance, "reasoning_min_steps"):
+ span.set_attribute(
+ SemanticConvention.GEN_AI_REASONING_MIN_STEPS, instance.reasoning_min_steps
+ )
+
+ if hasattr(instance, "reasoning_max_steps"):
+ span.set_attribute(
+ SemanticConvention.GEN_AI_REASONING_MAX_STEPS, instance.reasoning_max_steps
+ )
+
+ if hasattr(instance, "reasoning_model") and instance.reasoning_model:
+ reasoning_model_name = getattr(
+ instance.reasoning_model, "name", str(instance.reasoning_model)
+ )
+ span.set_attribute(
+ SemanticConvention.GEN_AI_REASONING_MODEL, reasoning_model_name
+ )
+
+ # Set execution time
+ span.set_attribute(
+ SemanticConvention.GEN_AI_REASONING_EXECUTION_DURATION, execution_time
+ )
+
+
+def process_vectordb_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ response,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ operation_type="vectordb_search",
+):
+ """
+ Process vectordb operation request and generate ALL telemetry attributes from semcov
+ """
+
+ execution_time = time.time() - start_time
+
+ # Create scope object for common_span_attributes compatibility
+ scope = _ScopeWrapper(span, instance, kwargs, args, start_time)
+
+ # Use common span attributes for vectordb operations
+ common_span_attributes(
+ scope,
+ f"gen_ai.operation.{operation_type}",
+ SemanticConvention.GEN_AI_SYSTEM_AGNO,
+ "localhost", # server_address
+ 80, # server_port
+ None, # request_model
+ None, # response_model
+ environment,
+ application_name,
+ False, # is_stream
+ 0, # tbt
+ 0, # ttft
+ version,
+ )
+
+ # Set vectordb-specific attributes using semcov
+ if hasattr(instance, "name"):
+ span.set_attribute(SemanticConvention.GEN_AI_VECTORDB_NAME, str(instance.name))
+
+ if hasattr(instance, "dimensions"):
+ span.set_attribute(
+ SemanticConvention.GEN_AI_VECTORDB_DIMENSIONS, instance.dimensions
+ )
+
+ # Search-specific attributes
+ if operation_type == "vectordb_search" and args:
+ query = args[0] if args else None
+ if query:
+ if isinstance(query, str):
+ span.set_attribute(
+ SemanticConvention.GEN_AI_VECTORDB_SEARCH_QUERY, query[:500]
+ )
+ elif hasattr(query, "__len__"):
+ span.set_attribute(
+ SemanticConvention.GEN_AI_VECTORDB_SEARCH_VECTOR_SIZE, len(query)
+ )
+
+ limit = kwargs.get("limit", args[1] if len(args) > 1 else None)
+ if limit:
+ span.set_attribute(SemanticConvention.GEN_AI_VECTORDB_SEARCH_LIMIT, limit)
+
+ # Upsert-specific attributes
+ if operation_type == "vectordb_upsert" and args:
+ documents = args[0] if args else None
+ if documents and hasattr(documents, "__len__"):
+ span.set_attribute(
+ SemanticConvention.GEN_AI_VECTORDB_UPSERT_DOCUMENT_COUNT, len(documents)
+ )
+
+ # Set execution metrics
+ span.set_attribute(
+ SemanticConvention.GEN_AI_VECTORDB_OPERATION_DURATION, execution_time
+ )
+
+ # Process result
+ if response:
+ span.set_attribute(SemanticConvention.GEN_AI_VECTORDB_OPERATION_SUCCESS, True)
+ if operation_type == "vectordb_search" and hasattr(response, "__len__"):
+ span.set_attribute(
+ SemanticConvention.GEN_AI_VECTORDB_SEARCH_RESULTS_COUNT, len(response)
+ )
+ if response and hasattr(response[0], "score"):
+ scores = [r.score for r in response[:5]] # Top 5 scores
+ span.set_attribute(
+ SemanticConvention.GEN_AI_VECTORDB_SEARCH_TOP_SCORES, scores
+ )
+ else:
+ span.set_attribute(SemanticConvention.GEN_AI_VECTORDB_OPERATION_SUCCESS, False)
+
+
+def process_knowledge_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ response,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+ operation_type="knowledge_search",
+):
+ """
+ Process knowledge operation request and generate ALL telemetry attributes from semcov
+ """
+
+ execution_time = time.time() - start_time
+
+ # Create scope object for common_span_attributes compatibility
+ scope = _ScopeWrapper(span, instance, kwargs, args, start_time)
+
+ # Use common span attributes for knowledge operations
+ common_span_attributes(
+ scope,
+ f"gen_ai.operation.{operation_type}",
+ SemanticConvention.GEN_AI_SYSTEM_AGNO,
+ "localhost", # server_address
+ 80, # server_port
+ None, # request_model
+ None, # response_model
+ environment,
+ application_name,
+ False, # is_stream
+ 0, # tbt
+ 0, # ttft
+ version,
+ )
+
+ # Search-specific attributes
+ if operation_type == "knowledge_search":
+ query = args[0] if args else None
+ if query and capture_message_content:
+ span.set_attribute(
+ SemanticConvention.GEN_AI_KNOWLEDGE_SEARCH_QUERY, query[:500]
+ )
+
+ limit = kwargs.get("limit", args[1] if len(args) > 1 else 5)
+ span.set_attribute(SemanticConvention.GEN_AI_KNOWLEDGE_SEARCH_LIMIT, limit)
+
+ # Add-specific attributes
+ if operation_type == "knowledge_add" and args:
+ documents = args[0] if args else None
+ if documents:
+ if hasattr(documents, "__len__"):
+ span.set_attribute(
+ SemanticConvention.GEN_AI_KNOWLEDGE_ADD_DOCUMENT_COUNT,
+ len(documents),
+ )
+ else:
+ span.set_attribute(
+ SemanticConvention.GEN_AI_KNOWLEDGE_ADD_CONTENT_LENGTH,
+ len(str(documents)),
+ )
+
+ # Set execution metrics
+ span.set_attribute(
+ SemanticConvention.GEN_AI_KNOWLEDGE_OPERATION_DURATION, execution_time
+ )
+
+ # Process result
+ if response:
+ span.set_attribute(SemanticConvention.GEN_AI_KNOWLEDGE_OPERATION_SUCCESS, True)
+ if operation_type == "knowledge_search" and hasattr(response, "__len__"):
+ span.set_attribute(
+ SemanticConvention.GEN_AI_KNOWLEDGE_SEARCH_RESULTS_COUNT, len(response)
+ )
+ else:
+ span.set_attribute(SemanticConvention.GEN_AI_KNOWLEDGE_OPERATION_SUCCESS, False)
+
+
+def process_workflow_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ response,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+):
+ """
+ Process workflow operation request and generate ALL telemetry attributes from semcov
+ """
+
+ execution_time = time.time() - start_time
+ workflow_name = getattr(instance, "name", "unknown_workflow")
+
+ # Create scope object for common_span_attributes compatibility
+ scope = _ScopeWrapper(span, instance, kwargs, args, start_time)
+
+ # Use common span attributes for workflow operations
+ common_span_attributes(
+ scope,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_WORKFLOW,
+ SemanticConvention.GEN_AI_SYSTEM_AGNO,
+ "localhost", # server_address
+ 80, # server_port
+ None, # request_model
+ None, # response_model
+ environment,
+ application_name,
+ False, # is_stream
+ 0, # tbt
+ 0, # ttft
+ version,
+ )
+
+ # Set workflow-specific attributes using semcov
+ span.set_attribute(SemanticConvention.GEN_AI_WORKFLOW_NAME, workflow_name)
+
+ if hasattr(instance, "agents") and instance.agents:
+ span.set_attribute(
+ SemanticConvention.GEN_AI_WORKFLOW_AGENT_COUNT, len(instance.agents)
+ )
+
+ if hasattr(instance, "description") and instance.description:
+ span.set_attribute(
+ SemanticConvention.GEN_AI_WORKFLOW_DESCRIPTION,
+ str(instance.description)[:300],
+ )
+
+ # Set execution metrics
+ span.set_attribute(
+ SemanticConvention.GEN_AI_WORKFLOW_EXECUTION_DURATION, execution_time
+ )
+ span.set_attribute(
+ SemanticConvention.GEN_AI_WORKFLOW_OPERATION_SUCCESS, response is not None
+ )
+
+
+def process_team_request(
+ span,
+ instance,
+ args,
+ kwargs,
+ response,
+ start_time,
+ pricing_info,
+ environment,
+ application_name,
+ metrics,
+ capture_message_content,
+ disable_metrics,
+ version,
+):
+ """
+ Process team operation request and generate ALL telemetry attributes from semcov
+ """
+
+ execution_time = time.time() - start_time
+ team_name = getattr(instance, "name", "unknown_team")
+
+ # Create scope object for common_span_attributes compatibility
+ scope = _ScopeWrapper(span, instance, kwargs, args, start_time)
+
+ # Use common span attributes for team operations
+ common_span_attributes(
+ scope,
+ SemanticConvention.GEN_AI_OPERATION_TYPE_TEAM,
+ SemanticConvention.GEN_AI_SYSTEM_AGNO,
+ "localhost", # server_address
+ 80, # server_port
+ None, # request_model
+ None, # response_model
+ environment,
+ application_name,
+ False, # is_stream
+ 0, # tbt
+ 0, # ttft
+ version,
+ )
+
+ # Set team-specific attributes using semcov
+ span.set_attribute(SemanticConvention.GEN_AI_TEAM_NAME, team_name)
+
+ if hasattr(instance, "agents") and instance.agents:
+ agent_names = [getattr(agent, "name", "unknown") for agent in instance.agents]
+ span.set_attribute(
+ SemanticConvention.GEN_AI_TEAM_AGENTS, agent_names[:10]
+ ) # Limit to 10
+ span.set_attribute(
+ SemanticConvention.GEN_AI_TEAM_AGENT_COUNT, len(instance.agents)
+ )
+
+ # Set execution metrics
+ span.set_attribute(
+ SemanticConvention.GEN_AI_TEAM_EXECUTION_DURATION, execution_time
+ )
+ span.set_attribute(
+ SemanticConvention.GEN_AI_TEAM_OPERATION_SUCCESS, response is not None
+ )
diff --git a/sdk/python/src/openlit/instrumentation/phidata/__init__.py b/sdk/python/src/openlit/instrumentation/phidata/__init__.py
deleted file mode 100644
index 657d4ae0..00000000
--- a/sdk/python/src/openlit/instrumentation/phidata/__init__.py
+++ /dev/null
@@ -1,50 +0,0 @@
-# pylint: disable=useless-return, bad-staticmethod-argument, disable=duplicate-code
-"""Initializer of Auto Instrumentation of Phidata Functions"""
-
-from typing import Collection
-import importlib.metadata
-from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
-from wrapt import wrap_function_wrapper
-
-from openlit.instrumentation.phidata.phidata import phidata_wrap
-
-_instruments = ("phidata >= 2.5.32",)
-
-
-class PhidataInstrumentor(BaseInstrumentor):
- """
- An instrumentor for Phidata's client library.
- """
-
- def instrumentation_dependencies(self) -> Collection[str]:
- return _instruments
-
- def _instrument(self, **kwargs):
- application_name = kwargs.get("application_name", "default_application")
- environment = kwargs.get("environment", "default_environment")
- tracer = kwargs.get("tracer")
- metrics = kwargs.get("metrics_dict")
- pricing_info = kwargs.get("pricing_info", {})
- capture_message_content = kwargs.get("capture_message_content", False)
- disable_metrics = kwargs.get("disable_metrics")
- version = importlib.metadata.version("phidata")
-
- wrap_function_wrapper(
- "phi.agent",
- "Agent.print_response",
- phidata_wrap(
- "phidata.print_response",
- version,
- environment,
- application_name,
- tracer,
- pricing_info,
- capture_message_content,
- metrics,
- disable_metrics,
- ),
- )
-
- def _uninstrument(self, **kwargs):
- # Proper uninstrumentation logic to revert patched methods
- pass
diff --git a/sdk/python/src/openlit/instrumentation/phidata/phidata.py b/sdk/python/src/openlit/instrumentation/phidata/phidata.py
deleted file mode 100644
index 5f843dc7..00000000
--- a/sdk/python/src/openlit/instrumentation/phidata/phidata.py
+++ /dev/null
@@ -1,135 +0,0 @@
-# pylint: disable=duplicate-code, broad-exception-caught, too-many-statements, unused-argument
-"""
-Module for monitoring Phidata calls.
-"""
-
-import logging
-from opentelemetry.trace import SpanKind, Status, StatusCode
-from opentelemetry.sdk.resources import (
- SERVICE_NAME,
- TELEMETRY_SDK_NAME,
- DEPLOYMENT_ENVIRONMENT,
-)
-from openlit.__helpers import (
- handle_exception,
-)
-from openlit.semcov import SemanticConvention
-
-# Initialize logger for logging potential issues and operations
-logger = logging.getLogger(__name__)
-
-
-def phidata_wrap(
- gen_ai_endpoint,
- version,
- environment,
- application_name,
- tracer,
- pricing_info,
- capture_message_content,
- metrics,
- disable_metrics,
-):
- """
- Generates a telemetry wrapper for chat completions to collect metrics.
-
- Args:
- gen_ai_endpoint: Endpoint identifier for logging and tracing.
- version: Version of the monitoring package.
- environment: Deployment environment (e.g., production, staging).
- application_name: Name of the application using the Phidata Agent.
- tracer: OpenTelemetry tracer for creating spans.
- pricing_info: Information used for calculating the cost of Phidata usage.
- capture_message_content: Flag indicating whether to trace the actual content.
-
- Returns:
- A function that wraps the chat completions method to add telemetry.
- """
-
- def wrapper(wrapped, instance, args, kwargs):
- """
- Wraps the 'chat.completions' API call to add telemetry.
-
- This collects metrics such as execution time, cost, and token usage, and handles errors
- gracefully, adding details to the trace for observability.
-
- Args:
- wrapped: The original 'chat.completions' method to be wrapped.
- instance: The instance of the class where the original method is defined.
- args: Positional arguments for the 'chat.completions' method.
- kwargs: Keyword arguments for the 'chat.completions' method.
-
- Returns:
- The response from the original 'chat.completions' method.
- """
-
- # pylint: disable=line-too-long
- with tracer.start_as_current_span(
- gen_ai_endpoint, kind=SpanKind.CLIENT
- ) as span:
- response = wrapped(*args, **kwargs)
-
- try:
- # Set base span attribues
- span.set_attribute(TELEMETRY_SDK_NAME, "openlit")
- span.set_attribute(
- SemanticConvention.GEN_AI_SYSTEM,
- SemanticConvention.GEN_AI_SYSTEM_PHIDATA,
- )
- span.set_attribute(
- SemanticConvention.GEN_AI_OPERATION,
- SemanticConvention.GEN_AI_OPERATION_TYPE_AGENT,
- )
- span.set_attribute(SemanticConvention.GEN_AI_ENDPOINT, gen_ai_endpoint)
- span.set_attribute(SERVICE_NAME, application_name)
- span.set_attribute(DEPLOYMENT_ENVIRONMENT, environment)
- span.set_attribute(
- SemanticConvention.GEN_AI_AGENT_ID,
- getattr(instance, "agent_id", "") or "",
- )
- span.set_attribute(
- SemanticConvention.GEN_AI_AGENT_ROLE,
- getattr(instance, "name", "") or "",
- )
- span.set_attribute(
- SemanticConvention.GEN_AI_REQUEST_MODEL,
- getattr(getattr(instance, "model", None), "id", "") or "",
- )
- span.set_attribute(
- SemanticConvention.GEN_AI_AGENT_TOOLS,
- str(getattr(instance, "tools", "")) or "",
- )
- span.set_attribute(
- SemanticConvention.GEN_AI_AGENT_CONTEXT,
- str(getattr(instance, "knowledge", "")) or "",
- )
- span.set_attribute(
- SemanticConvention.GEN_AI_AGENT_TASK,
- str(getattr(instance, "task", "")) or "",
- )
- span.set_attribute(
- SemanticConvention.GEN_AI_AGENT_INSTRUCTIONS,
- str(getattr(instance, "instructions", "")) or "",
- )
- span.set_attribute(
- SemanticConvention.GEN_AI_AGENT_STORAGE,
- str(getattr(instance, "storage", "")) or "",
- )
- span.set_attribute(
- SemanticConvention.GEN_AI_AGENT_ENABLE_HISTORY,
- str(getattr(instance, "add_history_to_messages", "")) or "",
- )
-
- span.set_status(Status(StatusCode.OK))
-
- # Return original response
- return response
-
- except Exception as e:
- handle_exception(span, e)
- logger.error("Error in trace creation: %s", e)
-
- # Return original response
- return response
-
- return wrapper
diff --git a/sdk/python/src/openlit/semcov/__init__.py b/sdk/python/src/openlit/semcov/__init__.py
index 7f3d8357..993572d0 100644
--- a/sdk/python/src/openlit/semcov/__init__.py
+++ b/sdk/python/src/openlit/semcov/__init__.py
@@ -140,7 +140,7 @@ class SemanticConvention:
GEN_AI_SYSTEM_AG2 = "ag2"
GEN_AI_SYSTEM_MULTION = "multion"
GEN_AI_SYSTEM_DYNAMIQ = "dynamiq"
- GEN_AI_SYSTEM_PHIDATA = "phidata"
+ GEN_AI_SYSTEM_AGNO = "agno"
GEN_AI_SYSTEM_JULEP = "julep"
GEN_AI_SYSTEM_AI21 = "ai21"
GEN_AI_SYSTEM_CONTROLFLOW = "controlflow"
@@ -595,3 +595,82 @@ class SemanticConvention:
# Streaming attributes (general, reusable)
GEN_AI_STREAMING_CHUNK_COUNT = "gen_ai.streaming.chunk_count"
GEN_AI_STREAMING_RESPONSE_COUNT = "gen_ai.streaming.response_count"
+
+ # Agent execution and performance attributes (only truly new ones)
+ GEN_AI_AGENT_INTRODUCTION = "gen_ai.agent.introduction"
+ GEN_AI_AGENT_MEMORY_ENABLED = "gen_ai.agent.memory_enabled"
+ GEN_AI_AGENT_EXECUTION_TIME = "gen_ai.agent.execution_time"
+ GEN_AI_AGENT_SHOW_REASONING = "gen_ai.agent.show_reasoning"
+ GEN_AI_AGENT_STREAM_INTERMEDIATE_STEPS = "gen_ai.agent.stream_intermediate_steps"
+ # Reuse existing: GEN_AI_REQUEST_USER, GEN_AI_SESSION_ID, GEN_AI_REQUEST_IS_STREAM
+
+ # Tool execution attributes (only truly new ones)
+ GEN_AI_TOOL_DESCRIPTION = "gen_ai.tool.description"
+ GEN_AI_TOOL_PARAMETERS = "gen_ai.tool.parameters"
+ GEN_AI_TOOL_INPUT_KWARGS = "gen_ai.tool.input_kwargs"
+ GEN_AI_TOOL_OUTPUT_TYPE = "gen_ai.tool.output_type"
+ GEN_AI_TOOL_ERROR = "gen_ai.tool.error"
+
+ # Toolkit attributes (new)
+ GEN_AI_TOOLKIT_NAME = "gen_ai.toolkit.name"
+ GEN_AI_TOOLKIT_FUNCTIONS = "gen_ai.toolkit.functions"
+ GEN_AI_TOOLKIT_FUNCTION_COUNT = "gen_ai.toolkit.function_count"
+ GEN_AI_TOOLKIT_EXECUTION_DURATION = "gen_ai.toolkit.execution.duration"
+
+ # Memory operation attributes (only truly new ones)
+ GEN_AI_MEMORY_OPERATION = "gen_ai.memory.operation"
+ GEN_AI_MEMORY_SESSION_ID = "gen_ai.memory.session_id"
+ GEN_AI_MEMORY_USER_ID = "gen_ai.memory.user_id"
+ GEN_AI_MEMORY_RESULTS_COUNT = "gen_ai.memory.results_count"
+ GEN_AI_MEMORY_DB_TYPE = "gen_ai.memory.db_type"
+ GEN_AI_MEMORY_TABLE_NAME = "gen_ai.memory.table_name"
+ GEN_AI_MEMORY_INPUT = "gen_ai.memory.input"
+ GEN_AI_MEMORY_AGENT_ID = "gen_ai.memory.agent_id"
+ GEN_AI_MEMORY_OPERATION_DURATION = "gen_ai.memory.operation.duration"
+ GEN_AI_MEMORY_OPERATION_SUCCESS = "gen_ai.memory.operation.success"
+ GEN_AI_MEMORY_RESULT_ID = "gen_ai.memory.result_id"
+ GEN_AI_MEMORY_SEARCH_RESULTS_COUNT = "gen_ai.memory.search.results_count"
+ GEN_AI_MEMORY_SEARCH_TOP_SCORES = "gen_ai.memory.search.top_scores"
+ # Reuse existing: GEN_AI_MEMORY_METADATA, GEN_AI_MEMORY_SEARCH_QUERY, GEN_AI_MEMORY_SEARCH_LIMIT
+
+ # VectorDB operation attributes (only truly new ones)
+ GEN_AI_VECTORDB_NAME = "gen_ai.vectordb.name"
+ GEN_AI_VECTORDB_DIMENSIONS = "gen_ai.vectordb.dimensions"
+ GEN_AI_VECTORDB_SEARCH_QUERY = "gen_ai.vectordb.search.query"
+ GEN_AI_VECTORDB_SEARCH_VECTOR_SIZE = "gen_ai.vectordb.search.vector_size"
+ GEN_AI_VECTORDB_SEARCH_LIMIT = "gen_ai.vectordb.search.limit"
+ GEN_AI_VECTORDB_SEARCH_RESULTS_COUNT = "gen_ai.vectordb.search.results_count"
+ GEN_AI_VECTORDB_SEARCH_TOP_SCORES = "gen_ai.vectordb.search.top_scores"
+ GEN_AI_VECTORDB_OPERATION_DURATION = "gen_ai.vectordb.operation.duration"
+ GEN_AI_VECTORDB_OPERATION_SUCCESS = "gen_ai.vectordb.operation.success"
+ GEN_AI_VECTORDB_UPSERT_DOCUMENT_COUNT = "gen_ai.vectordb.upsert.document_count"
+
+ # Knowledge base operation attributes (only truly new ones)
+ GEN_AI_KNOWLEDGE_SEARCH_QUERY = "gen_ai.knowledge.search.query"
+ GEN_AI_KNOWLEDGE_SEARCH_LIMIT = "gen_ai.knowledge.search.limit"
+ GEN_AI_KNOWLEDGE_SEARCH_RESULTS_COUNT = "gen_ai.knowledge.search.results_count"
+ GEN_AI_KNOWLEDGE_ADD_DOCUMENT_COUNT = "gen_ai.knowledge.add.document_count"
+ GEN_AI_KNOWLEDGE_ADD_CONTENT_LENGTH = "gen_ai.knowledge.add.content_length"
+ GEN_AI_KNOWLEDGE_OPERATION_DURATION = "gen_ai.knowledge.operation.duration"
+ GEN_AI_KNOWLEDGE_OPERATION_SUCCESS = "gen_ai.knowledge.operation.success"
+
+ # Workflow operation attributes (additional ones not already covered above)
+ GEN_AI_WORKFLOW_NAME = "gen_ai.workflow.name"
+ GEN_AI_WORKFLOW_DESCRIPTION = "gen_ai.workflow.description"
+ GEN_AI_WORKFLOW_EXECUTION_DURATION = "gen_ai.workflow.execution.duration"
+ GEN_AI_WORKFLOW_OPERATION_SUCCESS = "gen_ai.workflow.operation.success"
+
+ # Team operation attributes (additional ones not already covered above)
+ GEN_AI_TEAM_NAME = "gen_ai.team.name"
+ GEN_AI_TEAM_AGENTS = "gen_ai.team.agents"
+ GEN_AI_TEAM_AGENT_COUNT = "gen_ai.team.agent_count"
+ GEN_AI_TEAM_EXECUTION_DURATION = "gen_ai.team.execution.duration"
+ GEN_AI_TEAM_OPERATION_SUCCESS = "gen_ai.team.operation.success"
+
+ # Reasoning operation attributes (additional ones not already covered above)
+ GEN_AI_REASONING_MIN_STEPS = "gen_ai.reasoning.min_steps"
+ GEN_AI_REASONING_MAX_STEPS = "gen_ai.reasoning.max_steps"
+ GEN_AI_REASONING_MODEL = "gen_ai.reasoning.model"
+ GEN_AI_REASONING_EXECUTION_DURATION = "gen_ai.reasoning.execution_duration"
+
+ # Note: Most workflow and team attributes already exist above, only add truly new ones if needed