MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / on_event

Method on_event

atomic-agent/src/hook_log.rs:93–112  ·  view source on GitHub ↗
(&self, event: &Event<'_>, _: Context<'_, S>)

Source from the content-addressed store, hash-verified

91struct HookLogLayer(Arc<Mutex<Option<SessionLogEvent>>>);
92impl<S: Subscriber> Layer<S> for HookLogLayer {
93 fn on_event(&self, event: &Event<'_>, _: Context<'_, S>) {
94 if event.metadata().target() != "atomic::hook" {
95 return;
96 }
97 let mut fields = Fields::default();
98 event.record(&mut fields);
99 let mut get = |name: &str| fields.0.remove(name).unwrap_or_default();
100 let event = SessionLogEvent {
101 event_id: get("event_id"),
102 session_id: usable(Some(&get("session_id"))),
103 parent_session_id: usable(Some(&get("parent_session_id"))),
104 agent: get("agent"),
105 display_name: get("display_name"),
106 verb: get("verb"),
107 outcome: get("outcome"),
108 detail: Some(get("detail")).filter(|detail| !detail.is_empty()),
109 at: get("at"),
110 };
111 *self.0.lock().unwrap() = Some(event);
112 }
113}
114
115/// Emit structured tracing fields and synchronously commit the captured event

Callers

nothing calls this directly

Calls 8

usableFunction · 0.85
lockMethod · 0.80
removeMethod · 0.65
getFunction · 0.50
metadataMethod · 0.45
recordMethod · 0.45
is_emptyMethod · 0.45
unwrapMethod · 0.45

Tested by

no test coverage detected