canic_core/ids/
metrics.rs

1use candid::CandidType;
2use serde::{Deserialize, Serialize};
3
4///
5/// AccessMetricKind
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(
13    CandidType, Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize,
14)]
15#[remain::sorted]
16pub enum AccessMetricKind {
17    Auth,
18    Custom,
19    Env,
20    Guard,
21    Rule,
22}
23
24impl AccessMetricKind {
25    #[must_use]
26    pub const fn as_str(self) -> &'static str {
27        match self {
28            Self::Auth => "auth",
29            Self::Custom => "custom",
30            Self::Env => "env",
31            Self::Guard => "guard",
32            Self::Rule => "rule",
33        }
34    }
35}
36
37///
38/// SystemMetricKind
39///
40
41#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
42#[remain::sorted]
43pub enum SystemMetricKind {
44    CanisterCall,
45    CanisterStatus,
46    CreateCanister,
47    DeleteCanister,
48    DepositCycles,
49    HttpOutcall,
50    InstallCode,
51    RawRand,
52    ReinstallCode,
53    TimerScheduled,
54    UninstallCode,
55    UpdateSettings,
56    UpgradeCode,
57}