Skip to main content

canic_core/ids/
metrics.rs

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