1use super::tracer_events::TracerEvent;
7use std::collections::HashMap;
8
9pub struct NullTracer;
14
15impl NullTracer {
16 pub fn new() -> Self {
18 Self
19 }
20
21 pub fn is_enabled(&self) -> bool {
23 false
24 }
25
26 pub fn enable(&self) {
28 }
30
31 pub fn disable(&self) {
33 }
35
36 pub fn record_event(&self, _event: Box<dyn TracerEvent>) {
38 }
40
41 #[allow(clippy::too_many_arguments)]
43 pub fn record_llm_call(
44 &self,
45 _model: impl Into<String>,
46 _messages: Vec<HashMap<String, serde_json::Value>>,
47 _temperature: Option<f64>,
48 _tools: Option<Vec<HashMap<String, serde_json::Value>>>,
49 _source: impl Into<String>,
50 _correlation_id: impl Into<String>,
51 ) {
52 }
54
55 pub fn record_llm_response(
57 &self,
58 _model: impl Into<String>,
59 _content: impl Into<String>,
60 _tool_calls: Option<Vec<HashMap<String, serde_json::Value>>>,
61 _call_duration_ms: Option<f64>,
62 _source: impl Into<String>,
63 _correlation_id: impl Into<String>,
64 ) {
65 }
67
68 #[allow(clippy::too_many_arguments)]
70 pub fn record_llm_response_with_evidence(
71 &self,
72 _model: impl Into<String>,
73 _content: impl Into<String>,
74 _tool_calls: Option<Vec<HashMap<String, serde_json::Value>>>,
75 _call_duration_ms: Option<f64>,
76 _evidence: crate::llm::models::ResponseEvidence,
77 _source: impl Into<String>,
78 _correlation_id: impl Into<String>,
79 ) {
80 }
82
83 #[allow(clippy::too_many_arguments)]
85 pub fn record_tool_call(
86 &self,
87 _tool_name: impl Into<String>,
88 _arguments: HashMap<String, serde_json::Value>,
89 _result: serde_json::Value,
90 _caller: Option<String>,
91 _call_duration_ms: Option<f64>,
92 _source: impl Into<String>,
93 _correlation_id: impl Into<String>,
94 ) {
95 }
97
98 pub fn record_agent_interaction(
100 &self,
101 _from_agent: impl Into<String>,
102 _to_agent: impl Into<String>,
103 _event_type: impl Into<String>,
104 _event_id: Option<String>,
105 _source: impl Into<String>,
106 _correlation_id: impl Into<String>,
107 ) {
108 }
110
111 pub fn get_event_summaries(
113 &self,
114 _start_time: Option<f64>,
115 _end_time: Option<f64>,
116 _filter_func: Option<&dyn super::EventFilterFn>,
117 ) -> Vec<String> {
118 Vec::new()
119 }
120
121 pub fn get_last_n_summaries(
123 &self,
124 _n: usize,
125 _filter_func: Option<&dyn super::EventFilterFn>,
126 ) -> Vec<String> {
127 Vec::new()
128 }
129
130 pub fn count_events(
132 &self,
133 _start_time: Option<f64>,
134 _end_time: Option<f64>,
135 _filter_func: Option<&dyn super::EventFilterFn>,
136 ) -> usize {
137 0
138 }
139
140 pub fn clear(&self) {
142 }
144
145 pub fn len(&self) -> usize {
147 0
148 }
149
150 pub fn is_empty(&self) -> bool {
152 true
153 }
154}
155
156impl Default for NullTracer {
157 fn default() -> Self {
158 Self::new()
159 }
160}
161
162#[cfg(test)]
163mod tests {
164 use super::*;
165
166 #[test]
167 fn test_null_tracer_is_disabled() {
168 let tracer = NullTracer::new();
169 assert!(!tracer.is_enabled());
170 }
171
172 #[test]
173 fn test_null_tracer_enable_disable() {
174 let tracer = NullTracer::new();
175 tracer.enable();
176 assert!(!tracer.is_enabled());
177
178 tracer.disable();
179 assert!(!tracer.is_enabled());
180 }
181
182 #[test]
183 fn test_null_tracer_record_methods() {
184 let tracer = NullTracer::new();
185
186 tracer.record_llm_call("llama3.2", vec![], Some(0.7), None, "test", "corr-123");
188
189 tracer.record_llm_response(
190 "llama3.2",
191 "Hello, world!",
192 None,
193 Some(150.5),
194 "test",
195 "corr-456",
196 );
197
198 let mut args = HashMap::new();
199 args.insert("input".to_string(), serde_json::json!("test"));
200
201 tracer.record_tool_call(
202 "example_tool",
203 args,
204 serde_json::json!({"output": "result"}),
205 Some("agent1".to_string()),
206 Some(25.0),
207 "test",
208 "corr-789",
209 );
210
211 tracer.record_agent_interaction(
212 "agent1",
213 "agent2",
214 "message",
215 Some("evt-123".to_string()),
216 "test",
217 "corr-abc",
218 );
219
220 assert_eq!(tracer.len(), 0);
222 assert!(tracer.is_empty());
223 }
224
225 #[test]
226 fn test_null_tracer_query_methods() {
227 let tracer = NullTracer::new();
228
229 let summaries = tracer.get_event_summaries(None, None, None);
231 assert!(summaries.is_empty());
232
233 let last_summaries = tracer.get_last_n_summaries(10, None);
234 assert!(last_summaries.is_empty());
235
236 let count = tracer.count_events(None, None, None);
237 assert_eq!(count, 0);
238 }
239
240 #[test]
241 fn test_null_tracer_clear() {
242 let tracer = NullTracer::new();
243 tracer.clear();
244 assert!(tracer.is_empty());
245 }
246
247 #[test]
248 fn test_null_tracer_len() {
249 let tracer = NullTracer::new();
250 assert_eq!(tracer.len(), 0);
251 }
252}