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
//! Metrics collection, aggregation, and reporting plugin
//!
//! This plugin provides a comprehensive metrics system for game engines, supporting:
//! - Multiple metric types (Counter, Gauge, Histogram)
//! - Rich aggregations (Sum, Count, Average, Min, Max, Percentiles)
//! - Windowed data storage for memory efficiency
//! - Periodic snapshots and reports
//! - Hook-based customization
//! - Event-driven architecture
//!
//! # Quick Start
//!
//! ```no_run
//! use issun::plugin::metrics::{
//! MetricsPlugin, MetricDefinition, MetricId, MetricType,
//! RecordMetricRequested, MetricValue
//! };
//!
//! // 1. Add plugin to your game
//! let plugin = MetricsPlugin::new();
//!
//! // 2. Define a metric
//! let metric_id = MetricId::new("player_score");
//! let definition = MetricDefinition::new(
//! "player_score",
//! "Player Score",
//! "Total player score points",
//! MetricType::Counter,
//! "points"
//! );
//!
//! // 3. Record values
//! let timestamp = 1000; // game time or epoch time
//! let value = MetricValue::new(metric_id, 100.0, timestamp);
//!
//! // 4. Generate reports with aggregations
//! // See GenerateReportRequested event
//! ```
//!
//! # Metric Types
//!
//! - **Counter**: Monotonically increasing values (e.g., total kills, experience points)
//! - **Gauge**: Current state values (e.g., health, player count)
//! - **Histogram**: Value distributions (e.g., damage dealt, latency)
//!
//! # Aggregations
//!
//! - Sum, Count, Average
//! - Min, Max, Last
//! - Percentiles (P50, P95, P99)
//! - Rate (per second)
//!
//! # Architecture
//!
//! The plugin follows the standard issun plugin pattern:
//! - **Types**: Core data structures (MetricId, MetricValue, AggregatedMetric)
//! - **Registry**: Metric storage and aggregation logic
//! - **Reporting**: Snapshot and report generation
//! - **Hook**: Customization points for metric lifecycle events
//! - **Events**: Command and state events for async operations
//! - **System**: Event processing and coordination
//! - **Plugin**: Public API and configuration
// Re-export public API
pub use *;
pub use ;
pub use MetricsPlugin;
pub use ;
pub use ;
pub use MetricsSystem;
pub use ;