llm_memory_graph/observatory/mod.rs
1//! Observatory integration for real-time event streaming and metrics
2//!
3//! This module provides event streaming capabilities for monitoring and analyzing
4//! memory graph operations in real-time. Events can be published to external systems
5//! like Kafka, and metrics can be collected for performance monitoring.
6//!
7//! # Features
8//!
9//! - **Event Streaming**: Publish events for all graph operations
10//! - **Metrics Collection**: Track performance and usage metrics
11//! - **Pluggable Publishers**: Implement custom event publishers
12//! - **In-Memory Testing**: Built-in publisher for development and testing
13//!
14//! # Examples
15//!
16//! ```no_run
17//! use llm_memory_graph::observatory::{ObservatoryConfig, InMemoryPublisher};
18//! use llm_memory_graph::engine::AsyncMemoryGraph;
19//! use llm_memory_graph::Config;
20//! use std::sync::Arc;
21//!
22//! #[tokio::main]
23//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
24//! // Create an in-memory event publisher
25//! let publisher = Arc::new(InMemoryPublisher::new());
26//!
27//! // Configure observatory
28//! let obs_config = ObservatoryConfig::new()
29//! .enabled()
30//! .with_batch_size(50);
31//!
32//! // Create graph with observatory
33//! let config = Config::default();
34//! let graph = AsyncMemoryGraph::with_observatory(
35//! config,
36//! Some(publisher.clone()),
37//! obs_config
38//! ).await?;
39//!
40//! // Operations will now emit events
41//! let session = graph.create_session().await?;
42//!
43//! // Check published events
44//! let events = publisher.get_events().await;
45//! println!("Published {} events", events.len());
46//!
47//! Ok(())
48//! }
49//! ```
50
51pub mod config;
52pub mod emitter;
53pub mod events;
54pub mod kafka;
55pub mod metrics;
56pub mod prometheus;
57pub mod publisher;
58pub mod streaming;
59
60pub use config::ObservatoryConfig;
61pub use emitter::{AsyncEventEmitter, EmissionStatsSnapshot};
62pub use events::MemoryGraphEvent;
63pub use kafka::{
64 BatchingKafkaProducer, KafkaConfig, KafkaProducer, MockKafkaProducer, ProducerStats,
65};
66pub use metrics::{MemoryGraphMetrics, MetricsSnapshot};
67pub use prometheus::{
68 GrpcMetricsSnapshot, MetricsCounterSnapshot, MetricsGaugeSnapshot, PrometheusMetrics,
69 VaultMetricsSnapshot,
70};
71pub use publisher::{EventPublisher, InMemoryPublisher, NoOpPublisher};
72pub use streaming::{EventStream, InMemoryEventStream, MultiEventStream};