GatewayTraceHook
Defined in the protocols module.AI Agent Structural contract for tracing a gateway pipeline stage as a span. A hook is fired around each stage of the inbound -> agent -> tool -> delivery pipeline. Implementations return a context manager whose scope is the span: entering starts it, exiting ends it, and an exception propagating out marks the span as failed. The default core implementation (:class:
NullGatewayTraceHook) is a no-op so tracing is zero-cost when no
exporter is attached.
The contract is deliberately dependency-free: no OpenTelemetry import lives
in core. A praisonai-plugins exporter implements stage with
tracer.start_as_current_span(...) and carries the correlation id as a
span attribute. Example::
with self._trace.stage(
“agent.run”,
correlation_id=current_correlation_id(),
session=sid,
):
reply = await agent.astart(text)
Methods
stage()
Open a tracing scope for pipeline stage
name.Source
View on GitHub
praisonaiagents/gateway/protocols.py at line 4820
