pub struct JsonEventSink;Expand description
An EventSink that serializes events as one-line JSON to stdout.
Each event is output as a single JSON object on one line, suitable for ingestion by log aggregation systems (ELK, Loki, CloudWatch, etc.).
Fields vary by event type but always include event_type.
§Examples
use grafos_observe::json_log::JsonEventSink;
use grafos_observe::{FabricEvent, EventSink};
use grafos_observe::event::OpType;
let event = FabricEvent::OpCompleted {
op_type: OpType::Write,
duration_us: 500,
bytes: 1024,
};
// Format without printing
let json = JsonEventSink::format_event(&event);
assert!(json.contains(r#""event_type":"op_completed""#));
assert!(json.contains(r#""duration_us":500"#));Implementations§
Source§impl JsonEventSink
impl JsonEventSink
Sourcepub fn format_event(event: &FabricEvent) -> String
pub fn format_event(event: &FabricEvent) -> String
Format a FabricEvent as a JSON string.
The output always includes timestamp, layer, and event_type fields,
followed by event-specific fields.
Trait Implementations§
Source§impl EventSink for JsonEventSink
impl EventSink for JsonEventSink
Source§fn emit(&self, event: &FabricEvent)
fn emit(&self, event: &FabricEvent)
Consume an event. Implementations should not block.
Auto Trait Implementations§
impl Freeze for JsonEventSink
impl RefUnwindSafe for JsonEventSink
impl Send for JsonEventSink
impl Sync for JsonEventSink
impl Unpin for JsonEventSink
impl UnwindSafe for JsonEventSink
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more