Skip to main content

canic_core/ids/
metrics.rs

1//! Module: ids::metrics
2//!
3//! Responsibility: metric classification identifiers.
4//! Does not own: metric storage, aggregation, or emission.
5//! Boundary: exposes stable categories used by access and system metrics.
6
7use serde::{Deserialize, Serialize};
8
9///
10/// AccessMetricKind
11///
12/// Enumerates the access predicate kind that rejected the call.
13/// Access metrics are emitted only on denial.
14/// Custom predicates report AccessMetricKind::Custom.
15/// Predicate names are recorded separately alongside the kind.
16///
17
18#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
19#[remain::sorted]
20pub enum AccessMetricKind {
21    Auth,
22    Custom,
23    Env,
24    Guard,
25    Rule,
26}
27
28impl AccessMetricKind {
29    #[must_use]
30    pub const fn as_str(self) -> &'static str {
31        match self {
32            Self::Auth => "auth",
33            Self::Custom => "custom",
34            Self::Env => "env",
35            Self::Guard => "guard",
36            Self::Rule => "rule",
37        }
38    }
39}
40
41///
42/// SystemMetricKind
43///
44/// Enumerates platform operation families recorded by system metrics.
45///
46
47#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
48#[remain::sorted]
49pub enum SystemMetricKind {
50    CanisterCall,
51    CanisterStatus,
52    CreateCanister,
53    DeleteCanister,
54    DepositCycles,
55    HttpOutcall,
56    InstallCode,
57    RawRand,
58    ReinstallCode,
59    TimerScheduled,
60    UninstallCode,
61    UpdateSettings,
62    UpgradeCode,
63}