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 LifecycleMetricPhase {
Init,
PostUpgrade,
}
impl LifecycleMetricPhase {
#[must_use]
pub const fn metric_label(self) -> &'static str {
match self {
Self::Init => "init",
Self::PostUpgrade => "post_upgrade",
}
}
}
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[remain::sorted]
pub enum LifecycleMetricRole {
Nonroot,
Root,
}
impl LifecycleMetricRole {
#[must_use]
pub const fn metric_label(self) -> &'static str {
match self {
Self::Nonroot => "nonroot",
Self::Root => "root",
}
}
}
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[remain::sorted]
pub enum LifecycleMetricStage {
Bootstrap,
Runtime,
}
impl LifecycleMetricStage {
#[must_use]
pub const fn metric_label(self) -> &'static str {
match self {
Self::Bootstrap => "bootstrap",
Self::Runtime => "runtime",
}
}
}
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[remain::sorted]
pub enum LifecycleMetricOutcome {
Completed,
Failed,
Scheduled,
Skipped,
Started,
Waiting,
}
impl LifecycleMetricOutcome {
#[must_use]
pub const fn metric_label(self) -> &'static str {
match self {
Self::Completed => "completed",
Self::Failed => "failed",
Self::Scheduled => "scheduled",
Self::Skipped => "skipped",
Self::Started => "started",
Self::Waiting => "waiting",
}
}
}
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[remain::sorted]
pub enum WasmStoreMetricOperation {
BootstrapChunkSync,
ChunkPublish,
ChunkUpload,
ManifestPromote,
Prepare,
ReleasePublish,
SourceResolve,
}
impl WasmStoreMetricOperation {
#[must_use]
pub const fn metric_label(self) -> &'static str {
match self {
Self::BootstrapChunkSync => "bootstrap_chunk_sync",
Self::ChunkPublish => "chunk_publish",
Self::ChunkUpload => "chunk_upload",
Self::ManifestPromote => "manifest_promote",
Self::Prepare => "prepare",
Self::ReleasePublish => "release_publish",
Self::SourceResolve => "source_resolve",
}
}
}
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[remain::sorted]
pub enum WasmStoreMetricSource {
Bootstrap,
Embedded,
ManagedFleet,
Resolver,
Store,
TargetStore,
}
impl WasmStoreMetricSource {
#[must_use]
pub const fn metric_label(self) -> &'static str {
match self {
Self::Bootstrap => "bootstrap",
Self::Embedded => "embedded",
Self::ManagedFleet => "managed_fleet",
Self::Resolver => "resolver",
Self::Store => "store",
Self::TargetStore => "target_store",
}
}
}
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[remain::sorted]
pub enum WasmStoreMetricOutcome {
Completed,
Failed,
Skipped,
Started,
}
impl WasmStoreMetricOutcome {
#[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 WasmStoreMetricReason {
CacheHit,
CacheMiss,
Capacity,
HashMismatch,
InvalidState,
ManagementCall,
MissingChunk,
MissingManifest,
Ok,
StoreCall,
UnsupportedInline,
}
impl WasmStoreMetricReason {
#[must_use]
pub const fn metric_label(self) -> &'static str {
match self {
Self::CacheHit => "cache_hit",
Self::CacheMiss => "cache_miss",
Self::Capacity => "capacity",
Self::HashMismatch => "hash_mismatch",
Self::InvalidState => "invalid_state",
Self::ManagementCall => "management_call",
Self::MissingChunk => "missing_chunk",
Self::MissingManifest => "missing_manifest",
Self::Ok => "ok",
Self::StoreCall => "store_call",
Self::UnsupportedInline => "unsupported_inline",
}
}
}
#[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",
}
}
}