rive_models/
stats.rs

1use iso8601_timestamp::Timestamp;
2use serde::Deserialize;
3use std::collections::HashMap;
4
5/// Index access information
6#[derive(Deserialize, Debug, Clone)]
7pub struct IndexAccess {
8    /// Operations since timestamp
9    pub ops: i32,
10    /// Timestamp at which data keeping begun
11    pub since: Timestamp,
12}
13
14/// Collection index
15#[derive(Deserialize, Debug, Clone)]
16pub struct Index {
17    /// Index name
18    pub name: String,
19    /// Access information
20    pub accesses: IndexAccess,
21}
22
23/// Histogram entry
24#[derive(Deserialize, Debug, Clone)]
25pub struct LatencyHistogramEntry {
26    /// Time
27    pub micros: i64,
28    /// Count
29    pub count: i64,
30}
31
32/// Collection latency stats
33#[derive(Deserialize, Debug, Clone)]
34pub struct LatencyStats {
35    /// Total operations
36    pub ops: i64,
37    /// Timestamp at which data keeping begun
38    pub latency: i64,
39    /// Histogram representation of latency data
40    pub histogram: Vec<LatencyHistogramEntry>,
41}
42
43/// Collection storage stats
44#[derive(Deserialize, Debug, Clone)]
45#[serde(rename_all = "camelCase")]
46pub struct StorageStats {
47    /// Uncompressed data size
48    pub size: i64,
49    /// Data size on disk
50    pub storage_size: i64,
51    /// Total size of all indexes
52    pub total_index_size: i64,
53    /// Sum of storage size and total index size
54    pub total_size: i64,
55    /// Individual index sizes
56    pub index_sizes: HashMap<String, i64>,
57    /// Number of documents in collection
58    pub count: i64,
59    /// Average size of each document
60    pub avg_obj_size: i64,
61}
62
63/// Query collection scan stats
64#[derive(Deserialize, Debug, Clone)]
65#[serde(rename_all = "camelCase")]
66pub struct CollectionScans {
67    /// Number of total collection scans
68    pub total: i64,
69    /// Number of total collection scans not using a tailable cursor
70    pub non_tailable: i64,
71}
72
73/// Collection query execution stats
74#[derive(Deserialize, Debug, Clone)]
75#[serde(rename_all = "camelCase")]
76pub struct QueryExecStats {
77    /// Stats regarding collection scans
78    pub collection_scans: CollectionScans,
79}
80
81/// Collection stats
82#[derive(Deserialize, Debug, Clone)]
83#[serde(rename_all = "camelCase")]
84pub struct CollectionStats {
85    /// Namespace
86    pub ns: String,
87    /// Local time
88    pub local_time: Timestamp,
89    /// Latency stats
90    pub latency_stats: HashMap<String, LatencyStats>,
91    /// Query exec stats
92    pub query_exec_stats: QueryExecStats,
93    /// Number of documents in collection
94    pub count: u64,
95}
96
97/// Server Stats
98#[derive(Deserialize, Debug, Clone)]
99pub struct Stats {
100    /// Index usage information
101    pub indices: HashMap<String, Vec<Index>>,
102    /// Collection stats
103    pub coll_stats: HashMap<String, CollectionStats>,
104}