use candid::CandidType;
use serde::Deserialize;
#[derive(CandidType, Clone, Copy, Debug, Deserialize)]
#[remain::sorted]
pub enum MetricsKind {
Core,
Placement,
Platform,
Runtime,
Security,
Storage,
}
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[remain::sorted]
pub enum CanisterOpsMetricOperation {
Create,
Delete,
Install,
Reinstall,
Restore,
Snapshot,
Upgrade,
}
impl CanisterOpsMetricOperation {
#[must_use]
pub const fn metric_label(self) -> &'static str {
match self {
Self::Create => "create",
Self::Delete => "delete",
Self::Install => "install",
Self::Reinstall => "reinstall",
Self::Restore => "restore",
Self::Snapshot => "snapshot",
Self::Upgrade => "upgrade",
}
}
}
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[remain::sorted]
pub enum CanisterOpsMetricOutcome {
Completed,
Failed,
Skipped,
Started,
}
impl CanisterOpsMetricOutcome {
#[must_use]
pub const fn metric_label(self) -> &'static str {
match self {
Self::Completed => "completed",
Self::Failed => "failed",
Self::Skipped => "skipped",
Self::Started => "started",
}
}
}
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[remain::sorted]
pub enum CanisterOpsMetricReason {
AlreadyExists,
Cycles,
InvalidState,
ManagementCall,
MissingWasm,
NewAllocation,
NotFound,
Ok,
PolicyDenied,
PoolReuse,
PoolTopup,
StatePropagation,
Topology,
TopologyPropagation,
Unknown,
}
impl CanisterOpsMetricReason {
#[must_use]
pub const fn metric_label(self) -> &'static str {
match self {
Self::AlreadyExists => "already_exists",
Self::NewAllocation => "new_allocation",
Self::Cycles => "cycles",
Self::InvalidState => "invalid_state",
Self::ManagementCall => "management_call",
Self::MissingWasm => "missing_wasm",
Self::NotFound => "not_found",
Self::Ok => "ok",
Self::PolicyDenied => "policy_denied",
Self::PoolReuse => "pool_reuse",
Self::PoolTopup => "pool_topup",
Self::StatePropagation => "state_propagation",
Self::Topology => "topology",
Self::TopologyPropagation => "topology_propagation",
Self::Unknown => "unknown",
}
}
}
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[remain::sorted]
pub enum ManagementCallMetricOperation {
CanisterStatus,
ClearChunkStore,
CreateCanister,
DeleteCanister,
DepositCycles,
EcdsaPublicKey,
GetCycles,
InstallChunkedCode,
InstallCode,
LoadCanisterSnapshot,
RawRand,
SignWithEcdsa,
StopCanister,
StoredChunks,
TakeCanisterSnapshot,
UninstallCode,
UpdateSettings,
UploadChunk,
}
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[remain::sorted]
pub enum ManagementCallMetricOutcome {
Completed,
Failed,
Started,
}
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[remain::sorted]
pub enum ManagementCallMetricReason {
Infra,
Ok,
}
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[remain::sorted]
pub enum PlatformCallMetricSurface {
Generic,
Http,
Ledger,
Management,
}
impl PlatformCallMetricSurface {
#[must_use]
pub const fn metric_label(self) -> &'static str {
match self {
Self::Generic => "generic",
Self::Http => "http",
Self::Ledger => "ledger",
Self::Management => "management",
}
}
}
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[remain::sorted]
pub enum PlatformCallMetricMode {
BoundedWait,
UnboundedWait,
Update,
}
impl PlatformCallMetricMode {
#[must_use]
pub const fn metric_label(self) -> &'static str {
match self {
Self::BoundedWait => "bounded_wait",
Self::UnboundedWait => "unbounded_wait",
Self::Update => "update",
}
}
}
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[remain::sorted]
pub enum PlatformCallMetricOutcome {
Completed,
Failed,
Started,
}
impl PlatformCallMetricOutcome {
#[must_use]
pub const fn metric_label(self) -> &'static str {
match self {
Self::Completed => "completed",
Self::Failed => "failed",
Self::Started => "started",
}
}
}
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[remain::sorted]
pub enum PlatformCallMetricReason {
CandidDecode,
CandidEncode,
HttpStatus,
Infra,
LedgerRejected,
Ok,
}
impl PlatformCallMetricReason {
#[must_use]
pub const fn metric_label(self) -> &'static str {
match self {
Self::CandidDecode => "candid_decode",
Self::CandidEncode => "candid_encode",
Self::HttpStatus => "http_status",
Self::Infra => "infra",
Self::LedgerRejected => "ledger_rejected",
Self::Ok => "ok",
}
}
}