Expand description
Observatory integration for real-time event streaming and metrics
This module provides event streaming capabilities for monitoring and analyzing memory graph operations in real-time. Events can be published to external systems like Kafka, and metrics can be collected for performance monitoring.
§Features
- Event Streaming: Publish events for all graph operations
- Metrics Collection: Track performance and usage metrics
- Pluggable Publishers: Implement custom event publishers
- In-Memory Testing: Built-in publisher for development and testing
§Examples
use llm_memory_graph::observatory::{ObservatoryConfig, InMemoryPublisher};
use llm_memory_graph::engine::AsyncMemoryGraph;
use llm_memory_graph::Config;
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create an in-memory event publisher
let publisher = Arc::new(InMemoryPublisher::new());
// Configure observatory
let obs_config = ObservatoryConfig::new()
.enabled()
.with_batch_size(50);
// Create graph with observatory
let config = Config::default();
let graph = AsyncMemoryGraph::with_observatory(
config,
Some(publisher.clone()),
obs_config
).await?;
// Operations will now emit events
let session = graph.create_session().await?;
// Check published events
let events = publisher.get_events().await;
println!("Published {} events", events.len());
Ok(())
}Re-exports§
pub use config::ObservatoryConfig;pub use emitter::AsyncEventEmitter;pub use emitter::EmissionStatsSnapshot;pub use events::MemoryGraphEvent;pub use kafka::BatchingKafkaProducer;pub use kafka::KafkaConfig;pub use kafka::KafkaProducer;pub use kafka::MockKafkaProducer;pub use kafka::ProducerStats;pub use metrics::MemoryGraphMetrics;pub use metrics::MetricsSnapshot;pub use prometheus::GrpcMetricsSnapshot;pub use prometheus::MetricsCounterSnapshot;pub use prometheus::MetricsGaugeSnapshot;pub use prometheus::PrometheusMetrics;pub use prometheus::VaultMetricsSnapshot;pub use publisher::EventPublisher;pub use publisher::InMemoryPublisher;pub use publisher::NoOpPublisher;pub use streaming::EventStream;pub use streaming::InMemoryEventStream;pub use streaming::MultiEventStream;
Modules§
- config
- Configuration for Observatory integration
- emitter
- Async event emitter for non-blocking event emission
- events
- Event types for Observatory integration
- kafka
- Kafka producer with batching and retry logic
- metrics
- Metrics collection for memory graph operations
- prometheus
- Prometheus metrics integration for real-time monitoring
- publisher
- Event publisher traits and implementations
- streaming
- Real-time event streaming infrastructure