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 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",
}
}
}