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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
use iso8601_timestamp::Timestamp;
use serde::Deserialize;
use std::collections::HashMap;
/// Index access information
#[derive(Deserialize, Debug, Clone)]
pub struct IndexAccess {
/// Operations since timestamp
pub ops: i32,
/// Timestamp at which data keeping begun
pub since: Timestamp,
}
/// Collection index
#[derive(Deserialize, Debug, Clone)]
pub struct Index {
/// Index name
pub name: String,
/// Access information
pub accesses: IndexAccess,
}
/// Histogram entry
#[derive(Deserialize, Debug, Clone)]
pub struct LatencyHistogramEntry {
/// Time
pub micros: i64,
/// Count
pub count: i64,
}
/// Collection latency stats
#[derive(Deserialize, Debug, Clone)]
pub struct LatencyStats {
/// Total operations
pub ops: i64,
/// Timestamp at which data keeping begun
pub latency: i64,
/// Histogram representation of latency data
pub histogram: Vec<LatencyHistogramEntry>,
}
/// Collection storage stats
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct StorageStats {
/// Uncompressed data size
pub size: i64,
/// Data size on disk
pub storage_size: i64,
/// Total size of all indexes
pub total_index_size: i64,
/// Sum of storage size and total index size
pub total_size: i64,
/// Individual index sizes
pub index_sizes: HashMap<String, i64>,
/// Number of documents in collection
pub count: i64,
/// Average size of each document
pub avg_obj_size: i64,
}
/// Query collection scan stats
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct CollectionScans {
/// Number of total collection scans
pub total: i64,
/// Number of total collection scans not using a tailable cursor
pub non_tailable: i64,
}
/// Collection query execution stats
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct QueryExecStats {
/// Stats regarding collection scans
pub collection_scans: CollectionScans,
}
/// Collection stats
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
pub struct CollectionStats {
/// Namespace
pub ns: String,
/// Local time
pub local_time: Timestamp,
/// Latency stats
pub latency_stats: HashMap<String, LatencyStats>,
/// Query exec stats
pub query_exec_stats: QueryExecStats,
/// Number of documents in collection
pub count: u64,
}
/// Server Stats
#[derive(Deserialize, Debug, Clone)]
pub struct Stats {
/// Index usage information
pub indices: HashMap<String, Vec<Index>>,
/// Collection stats
pub coll_stats: HashMap<String, CollectionStats>,
}