1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//! `MockForge` Analytics
//!
//! Provides comprehensive traffic analytics and metrics dashboard capabilities
//! for `MockForge`, including:
//!
//! - Time-series metrics aggregation (minute/hour/day granularity)
//! - Endpoint performance tracking
//! - Error analysis and monitoring
//! - Client analytics
//! - Traffic pattern detection
//! - Data export (CSV, JSON)
//! - Configurable retention policies
//!
//! # Architecture
//!
//! The analytics system consists of several components:
//!
//! - **Database**: SQLite-based storage for aggregated metrics
//! - **Aggregator**: Background service that queries Prometheus and stores metrics
//! - **Queries**: High-level query API for dashboard data
//! - **Export**: Data export functionality
//! - **Retention**: Automatic cleanup of old data
//!
//! # Example
//!
//! ```no_run
//! use mockforge_analytics::{AnalyticsDatabase, AnalyticsConfig, RetentionConfig};
//! use std::path::PathBuf;
//!
//! # async fn example() -> anyhow::Result<()> {
//! let config = AnalyticsConfig {
//! enabled: true,
//! database_path: PathBuf::from("analytics.db"),
//! aggregation_interval_seconds: 60,
//! rollup_interval_hours: 1,
//! retention: RetentionConfig::default(),
//! batch_size: 1000,
//! max_query_results: 10000,
//! };
//!
//! let db = AnalyticsDatabase::new(&config.database_path).await?;
//! db.run_migrations().await?;
//!
//! // Query top endpoints
//! let endpoints = db.get_top_endpoints(10, None).await?;
//! for endpoint in &endpoints {
//! println!("Endpoint: {} - {} requests", endpoint.endpoint, endpoint.total_requests);
//! }
//! # Ok(())
//! # }
//! ```
pub use ;
pub use AnalyticsDatabase;
pub use ;
pub use *;
pub use *;
// Explicitly re-export coverage metrics types for easier importing
pub use ;
/// Initialize the analytics system with the given configuration
///
/// # Errors
///
/// Returns an error if the database cannot be opened or migrations fail.
pub async