类 OtelTracingMiddleware
java.lang.Object
io.agentscope.core.tracing.OtelTracingMiddleware
- 所有已实现的接口:
MiddlewareBase
Middleware that adds OpenTelemetry tracing to the agent lifecycle.
Produces spans for:
invoke_agent <name>— wraps the entire replychat <model>— wraps each model API callexecute_tool <name>— wraps each tool execution
Context propagation across Reactor's asynchronous chain (including thread
hops via publishOn / subscribeOn) is handled by
ContextPropagationOperator
The global lift hook is registered once on class load, so child spans see
the correct parent regardless of which thread the signal lands on.
When no OTel SDK is configured (only the default no-op provider is active), every hook short-circuits with near-zero overhead.
Usage:
ReActAgent agent = ReActAgent.builder()
.name("assistant")
.model(model)
.middleware(new OtelTracingMiddleware())
.build();
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明reactor.core.publisher.Flux<AgentEvent> onActing(Agent agent, RuntimeContext ctx, ActingInput input, Function<ActingInput, reactor.core.publisher.Flux<AgentEvent>> next) Intercept the tool-call execution phase.reactor.core.publisher.Flux<AgentEvent> onAgent(Agent agent, RuntimeContext ctx, AgentInput input, Function<AgentInput, reactor.core.publisher.Flux<AgentEvent>> next) Intercept the entire agent invocation.reactor.core.publisher.Flux<AgentEvent> onModelCall(Agent agent, RuntimeContext ctx, ModelCallInput input, Function<ModelCallInput, reactor.core.publisher.Flux<AgentEvent>> next) Intercept the raw model API call.从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 io.agentscope.core.middleware.MiddlewareBase
onReasoning, onSystemPrompt
-
构造器详细资料
-
OtelTracingMiddleware
public OtelTracingMiddleware()
-
-
方法详细资料
-
onAgent
public reactor.core.publisher.Flux<AgentEvent> onAgent(Agent agent, RuntimeContext ctx, AgentInput input, Function<AgentInput, reactor.core.publisher.Flux<AgentEvent>> next) 从接口复制的说明:MiddlewareBaseIntercept the entire agent invocation.- 指定者:
onAgent在接口中MiddlewareBase- 参数:
agent- the agent instancectx- per-call runtime context (session, user, attributes)input- agent input (messages)next- calls the next middleware or the core agent logic- 返回:
- event stream from the agent invocation
-
onModelCall
public reactor.core.publisher.Flux<AgentEvent> onModelCall(Agent agent, RuntimeContext ctx, ModelCallInput input, Function<ModelCallInput, reactor.core.publisher.Flux<AgentEvent>> next) 从接口复制的说明:MiddlewareBaseIntercept the raw model API call.- 指定者:
onModelCall在接口中MiddlewareBase- 参数:
agent- the agent instancectx- per-call runtime context (session, user, attributes)input- model-call input (messages, tools, options, model)next- calls the next middleware or the actual model invocation- 返回:
- event stream from the model call
-
onActing
public reactor.core.publisher.Flux<AgentEvent> onActing(Agent agent, RuntimeContext ctx, ActingInput input, Function<ActingInput, reactor.core.publisher.Flux<AgentEvent>> next) 从接口复制的说明:MiddlewareBaseIntercept the tool-call execution phase.- 指定者:
onActing在接口中MiddlewareBase- 参数:
agent- the agent instancectx- per-call runtime context (session, user, attributes)input- acting input (the tool calls)next- calls the next middleware or the core acting logic- 返回:
- event stream from acting
-