Skip to main content

canic_core/dto/
metrics.rs

1use crate::dto::prelude::*;
2
3//
4// Metrics DTOs
5//
6
7//
8// MetricsKind
9//
10// Metric family selector.
11//
12
13#[derive(CandidType, Clone, Copy, Deserialize)]
14#[remain::sorted]
15pub enum MetricsKind {
16    Access,
17    Auth,
18    CanisterOps,
19    Cascade,
20    CyclesFunding,
21    CyclesTopup,
22    DelegatedAuth,
23    Directory,
24    Http,
25    Intent,
26    InterCanisterCall,
27    Lifecycle,
28    Perf,
29    PlatformCall,
30    Pool,
31    Provisioning,
32    Replay,
33    RootCapability,
34    Scaling,
35    #[cfg(feature = "sharding")]
36    Sharding,
37    System,
38    Timer,
39    WasmStore,
40}
41
42//
43// MetricEntry
44//
45// Unified metrics row.
46//
47
48#[derive(CandidType, Deserialize)]
49pub struct MetricEntry {
50    // Ordered labels.
51    pub labels: Vec<String>,
52
53    // Optional principal dimension.
54    pub principal: Option<Principal>,
55
56    // Metric payload.
57    pub value: MetricValue,
58}
59
60//
61// MetricValue
62//
63
64#[derive(CandidType, Deserialize)]
65pub enum MetricValue {
66    Count(u64),
67    CountAndU64 { count: u64, value_u64: u64 },
68    U128(u128),
69}
70
71//
72// QueryPerfSample
73//
74// Same-call query performance sample.
75//
76
77#[derive(CandidType, Deserialize)]
78pub struct QueryPerfSample<T> {
79    // Query result returned by the probe.
80    pub value: T,
81
82    // Local instruction counter observed in the same query call context.
83    pub local_instructions: u64,
84}