Skip to main content

canic_core/ids/
metrics.rs

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