77 AgnoModelWrapper ,
88)
99from opentelemetry import trace as trace_api
10+ from opentelemetry .instrumentation .utils import unwrap
1011from opentelemetry .instrumentation .instrumentor import BaseInstrumentor
1112from opentelemetry .instrumentation .version import (
1213 __version__ ,
1314)
1415
15- """OpenTelemetry exporters for BlackSheep instrumentation"""
16+ """OpenTelemetry exporters for Agno https://github.com/agno-agi/agno"""
17+
1618_AGENT = "agno.agent"
1719_MODULE = "agno.models.base"
1820_TOOLKIT = "agno.tools.function"
@@ -93,57 +95,20 @@ def _instrument(self, **kwargs: Any) -> None:
9395 def _uninstrument (self , ** kwargs : Any ) -> None :
9496
9597 # Unwrap the agent call function
96- wrap_function_wrapper (
97- module = _AGENT ,
98- name = "Agent._run" ,
99- wrapper = None ,
100- )
101- wrap_function_wrapper (
102- module = _AGENT ,
103- name = "Agent._arun" ,
104- wrapper = None ,
105- )
106- wrap_function_wrapper (
107- module = _AGENT ,
108- name = "Agent._run_stream" ,
109- wrapper = None ,
110- )
111- wrap_function_wrapper (
112- module = _AGENT ,
113- name = "Agent._arun_stream" ,
114- wrapper = None ,
115- )
98+ import agno .agent
99+ unwrap (agno .agent .Agent , "_run" )
100+ unwrap (agno .agent .Agent , "_arun" )
101+ unwrap (agno .agent .Agent , "_run_stream" )
102+ unwrap (agno .agent .Agent , "_arun_stream" )
116103
117104 # Unwrap the function call
118- wrap_function_wrapper (
119- module = _TOOLKIT ,
120- name = "FunctionCall.execute" ,
121- wrapper = None ,
122- )
123- wrap_function_wrapper (
124- module = _TOOLKIT ,
125- name = "FunctionCall.aexecute" ,
126- wrapper = None ,
127- )
105+ import agno .tools .function
106+ unwrap (agno .tools .function .FunctionCall , "execute" )
107+ unwrap (agno .tools .function .FunctionCall , "aexecute" )
128108
129109 # Unwrap the model
130- wrap_function_wrapper (
131- module = _MODULE ,
132- name = "Model.response" ,
133- wrapper = None ,
134- )
135- wrap_function_wrapper (
136- module = _MODULE ,
137- name = "Model.aresponse" ,
138- wrapper = None ,
139- )
140- wrap_function_wrapper (
141- module = _MODULE ,
142- name = "Model.response_stream" ,
143- wrapper = None ,
144- )
145- wrap_function_wrapper (
146- module = _MODULE ,
147- name = "Model.aresponse_stream" ,
148- wrapper = None ,
149- )
110+ import agno .models .base
111+ unwrap (agno .models .base .Model , "response" )
112+ unwrap (agno .models .base .Model , "aresponse" )
113+ unwrap (agno .models .base .Model , "response_stream" )
114+ unwrap (agno .models .base .Model , "aresponse_stream" )
0 commit comments