9797from opentelemetry .util .genai .types import Error
9898
9999
100- class ExtendedTelemetryHandler (TelemetryHandler ):
100+ class ExtendedTelemetryHandler (TelemetryHandler ): # pylint: disable=too-many-public-methods
101101 """
102102 Extended Telemetry Handler that supports additional GenAI operations.
103103 This class extends the base TelemetryHandler to support:
@@ -132,9 +132,9 @@ def start_create_agent(
132132 )
133133 return invocation
134134
135- def stop_create_agent (
135+ def stop_create_agent ( # pylint: disable=no-self-use
136136 self , invocation : CreateAgentInvocation
137- ) -> CreateAgentInvocation : # pylint: disable=no-self-use
137+ ) -> CreateAgentInvocation :
138138 """Finalize an agent creation invocation successfully and end its span."""
139139 if invocation .context_token is None or invocation .span is None :
140140 return invocation
@@ -190,9 +190,9 @@ def start_embedding(
190190 )
191191 return invocation
192192
193- def stop_embedding (
193+ def stop_embedding ( # pylint: disable=no-self-use
194194 self , invocation : EmbeddingInvocation
195- ) -> EmbeddingInvocation : # pylint: disable=no-self-use
195+ ) -> EmbeddingInvocation :
196196 """Finalize an embedding invocation successfully and end its span."""
197197 if invocation .context_token is None or invocation .span is None :
198198 return invocation
@@ -248,9 +248,9 @@ def start_execute_tool(
248248 )
249249 return invocation
250250
251- def stop_execute_tool (
251+ def stop_execute_tool ( # pylint: disable=no-self-use
252252 self , invocation : ExecuteToolInvocation
253- ) -> ExecuteToolInvocation : # pylint: disable=no-self-use
253+ ) -> ExecuteToolInvocation :
254254 """Finalize a tool execution invocation successfully and end its span."""
255255 if invocation .context_token is None or invocation .span is None :
256256 return invocation
@@ -321,7 +321,9 @@ def stop_invoke_agent(
321321 return invocation
322322
323323 _apply_invoke_agent_finish_attributes (invocation .span , invocation )
324- _maybe_emit_invoke_agent_event (self ._logger , invocation )
324+ _maybe_emit_invoke_agent_event (
325+ self ._logger , invocation .span , invocation
326+ )
325327 otel_context .detach (invocation .context_token )
326328 invocation .span .end ()
327329 return invocation
@@ -333,11 +335,12 @@ def fail_invoke_agent( # pylint: disable=no-self-use
333335 if invocation .context_token is None or invocation .span is None :
334336 return invocation
335337
336- _apply_invoke_agent_finish_attributes (invocation .span , invocation )
337- _apply_error_attributes (invocation .span , error )
338- _maybe_emit_invoke_agent_event (self ._logger , invocation , error )
338+ span = invocation .span
339+ _apply_invoke_agent_finish_attributes (span , invocation )
340+ _apply_error_attributes (span , error )
341+ _maybe_emit_invoke_agent_event (self ._logger , span , invocation , error ) # pylint: disable=too-many-function-args
339342 otel_context .detach (invocation .context_token )
340- invocation . span .end ()
343+ span .end ()
341344 return invocation
342345
343346 @contextmanager
@@ -373,9 +376,9 @@ def start_retrieve(
373376 )
374377 return invocation
375378
376- def stop_retrieve (
379+ def stop_retrieve ( # pylint: disable=no-self-use
377380 self , invocation : RetrieveInvocation
378- ) -> RetrieveInvocation : # pylint: disable=no-self-use
381+ ) -> RetrieveInvocation :
379382 """Finalize a retrieve documents invocation successfully and end its span."""
380383 if invocation .context_token is None or invocation .span is None :
381384 return invocation
0 commit comments