synaptic_callbacks/
tracing_cb.rs1use async_trait::async_trait;
2use synaptic_core::{CallbackHandler, RunEvent, SynapticError};
3
4pub struct TracingCallback;
5
6impl TracingCallback {
7 pub fn new() -> Self {
8 Self
9 }
10}
11
12impl Default for TracingCallback {
13 fn default() -> Self {
14 Self::new()
15 }
16}
17
18#[async_trait]
19impl CallbackHandler for TracingCallback {
20 async fn on_event(&self, event: RunEvent) -> Result<(), SynapticError> {
21 match event {
22 RunEvent::RunStarted { run_id, session_id } => {
23 tracing::info!(run_id = %run_id, session_id = %session_id, "run started");
24 }
25 RunEvent::RunStep { run_id, step } => {
26 tracing::info!(run_id = %run_id, step = step, "run step");
27 }
28 RunEvent::LlmCalled {
29 run_id,
30 message_count,
31 } => {
32 tracing::info!(run_id = %run_id, message_count = message_count, "LLM called");
33 }
34 RunEvent::ToolCalled { run_id, tool_name } => {
35 tracing::info!(run_id = %run_id, tool_name = %tool_name, "tool called");
36 }
37 RunEvent::RunFinished { run_id, output } => {
38 tracing::info!(run_id = %run_id, output_len = output.len(), "run finished");
39 }
40 RunEvent::RunFailed { run_id, error } => {
41 tracing::error!(run_id = %run_id, error = %error, "run failed");
42 }
43 }
44 Ok(())
45 }
46}