a2a_rs/adapter/
interceptor.rs1#[cfg(feature = "tracing")]
7use async_trait::async_trait;
8
9#[cfg(feature = "tracing")]
10use crate::domain::A2AError;
11#[cfg(feature = "tracing")]
12use crate::port::{CallContext, CallInterceptor};
13
14#[cfg(feature = "tracing")]
21#[derive(Debug, Clone, Default)]
22pub struct LoggingInterceptor;
23
24#[cfg(feature = "tracing")]
25#[async_trait]
26impl CallInterceptor for LoggingInterceptor {
27 async fn before(&self, ctx: &CallContext) -> Result<(), A2AError> {
28 tracing::debug!(method = %ctx.method, side = ?ctx.side, "A2A call started");
29 Ok(())
30 }
31
32 async fn after(&self, ctx: &CallContext, outcome: Result<(), &A2AError>) {
33 match outcome {
34 Ok(()) => {
35 tracing::debug!(method = %ctx.method, side = ?ctx.side, "A2A call succeeded")
36 }
37 Err(e) => {
38 tracing::warn!(method = %ctx.method, side = ?ctx.side, error = %e, "A2A call failed")
39 }
40 }
41 }
42}