1use candid::CandidType;
11use serde::Deserialize;
12
13#[derive(CandidType, Clone, Copy, Debug, Deserialize)]
20#[remain::sorted]
21pub enum MetricsKind {
22 Core,
23 Placement,
24 Platform,
25 Runtime,
26 Security,
27 Storage,
28}
29
30#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
37#[remain::sorted]
38pub enum CanisterOpsMetricOperation {
39 Create,
40 Delete,
41 Install,
42 Reinstall,
43 Restore,
44 Snapshot,
45 Upgrade,
46}
47
48impl CanisterOpsMetricOperation {
49 #[must_use]
51 pub const fn metric_label(self) -> &'static str {
52 match self {
53 Self::Create => "create",
54 Self::Delete => "delete",
55 Self::Install => "install",
56 Self::Reinstall => "reinstall",
57 Self::Restore => "restore",
58 Self::Snapshot => "snapshot",
59 Self::Upgrade => "upgrade",
60 }
61 }
62}
63
64#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
71#[remain::sorted]
72pub enum CanisterOpsMetricOutcome {
73 Completed,
74 Failed,
75 Skipped,
76 Started,
77}
78
79impl CanisterOpsMetricOutcome {
80 #[must_use]
82 pub const fn metric_label(self) -> &'static str {
83 match self {
84 Self::Completed => "completed",
85 Self::Failed => "failed",
86 Self::Skipped => "skipped",
87 Self::Started => "started",
88 }
89 }
90}
91
92#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
99#[remain::sorted]
100pub enum CanisterOpsMetricReason {
101 AlreadyExists,
102 Cycles,
103 InvalidState,
104 ManagementCall,
105 MissingWasm,
106 NewAllocation,
107 NotFound,
108 Ok,
109 PolicyDenied,
110 PoolReuse,
111 PoolTopup,
112 StatePropagation,
113 Topology,
114 TopologyPropagation,
115 Unknown,
116}
117
118impl CanisterOpsMetricReason {
119 #[must_use]
121 pub const fn metric_label(self) -> &'static str {
122 match self {
123 Self::AlreadyExists => "already_exists",
124 Self::NewAllocation => "new_allocation",
125 Self::Cycles => "cycles",
126 Self::InvalidState => "invalid_state",
127 Self::ManagementCall => "management_call",
128 Self::MissingWasm => "missing_wasm",
129 Self::NotFound => "not_found",
130 Self::Ok => "ok",
131 Self::PolicyDenied => "policy_denied",
132 Self::PoolReuse => "pool_reuse",
133 Self::PoolTopup => "pool_topup",
134 Self::StatePropagation => "state_propagation",
135 Self::Topology => "topology",
136 Self::TopologyPropagation => "topology_propagation",
137 Self::Unknown => "unknown",
138 }
139 }
140}
141
142#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
149#[remain::sorted]
150pub enum LifecycleMetricPhase {
151 Init,
152 PostUpgrade,
153}
154
155impl LifecycleMetricPhase {
156 #[must_use]
158 pub const fn metric_label(self) -> &'static str {
159 match self {
160 Self::Init => "init",
161 Self::PostUpgrade => "post_upgrade",
162 }
163 }
164}
165
166#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
173#[remain::sorted]
174pub enum LifecycleMetricRole {
175 Nonroot,
176 Root,
177}
178
179impl LifecycleMetricRole {
180 #[must_use]
182 pub const fn metric_label(self) -> &'static str {
183 match self {
184 Self::Nonroot => "nonroot",
185 Self::Root => "root",
186 }
187 }
188}
189
190#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
197#[remain::sorted]
198pub enum LifecycleMetricStage {
199 Bootstrap,
200 Runtime,
201}
202
203impl LifecycleMetricStage {
204 #[must_use]
206 pub const fn metric_label(self) -> &'static str {
207 match self {
208 Self::Bootstrap => "bootstrap",
209 Self::Runtime => "runtime",
210 }
211 }
212}
213
214#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
221#[remain::sorted]
222pub enum LifecycleMetricOutcome {
223 Completed,
224 Failed,
225 Scheduled,
226 Skipped,
227 Started,
228 Waiting,
229}
230
231impl LifecycleMetricOutcome {
232 #[must_use]
234 pub const fn metric_label(self) -> &'static str {
235 match self {
236 Self::Completed => "completed",
237 Self::Failed => "failed",
238 Self::Scheduled => "scheduled",
239 Self::Skipped => "skipped",
240 Self::Started => "started",
241 Self::Waiting => "waiting",
242 }
243 }
244}
245
246#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
253#[remain::sorted]
254pub enum WasmStoreMetricOperation {
255 BootstrapChunkSync,
256 ChunkPublish,
257 ChunkUpload,
258 ManifestPromote,
259 Prepare,
260 ReleasePublish,
261 SourceResolve,
262}
263
264impl WasmStoreMetricOperation {
265 #[must_use]
267 pub const fn metric_label(self) -> &'static str {
268 match self {
269 Self::BootstrapChunkSync => "bootstrap_chunk_sync",
270 Self::ChunkPublish => "chunk_publish",
271 Self::ChunkUpload => "chunk_upload",
272 Self::ManifestPromote => "manifest_promote",
273 Self::Prepare => "prepare",
274 Self::ReleasePublish => "release_publish",
275 Self::SourceResolve => "source_resolve",
276 }
277 }
278}
279
280#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
287#[remain::sorted]
288pub enum WasmStoreMetricSource {
289 Bootstrap,
290 Embedded,
291 ManagedFleet,
292 Resolver,
293 Store,
294 TargetStore,
295}
296
297impl WasmStoreMetricSource {
298 #[must_use]
300 pub const fn metric_label(self) -> &'static str {
301 match self {
302 Self::Bootstrap => "bootstrap",
303 Self::Embedded => "embedded",
304 Self::ManagedFleet => "managed_fleet",
305 Self::Resolver => "resolver",
306 Self::Store => "store",
307 Self::TargetStore => "target_store",
308 }
309 }
310}
311
312#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
319#[remain::sorted]
320pub enum WasmStoreMetricOutcome {
321 Completed,
322 Failed,
323 Skipped,
324 Started,
325}
326
327impl WasmStoreMetricOutcome {
328 #[must_use]
330 pub const fn metric_label(self) -> &'static str {
331 match self {
332 Self::Completed => "completed",
333 Self::Failed => "failed",
334 Self::Skipped => "skipped",
335 Self::Started => "started",
336 }
337 }
338}
339
340#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
347#[remain::sorted]
348pub enum WasmStoreMetricReason {
349 CacheHit,
350 CacheMiss,
351 Capacity,
352 HashMismatch,
353 InvalidState,
354 ManagementCall,
355 MissingChunk,
356 MissingManifest,
357 Ok,
358 StoreCall,
359 UnsupportedInline,
360}
361
362impl WasmStoreMetricReason {
363 #[must_use]
365 pub const fn metric_label(self) -> &'static str {
366 match self {
367 Self::CacheHit => "cache_hit",
368 Self::CacheMiss => "cache_miss",
369 Self::Capacity => "capacity",
370 Self::HashMismatch => "hash_mismatch",
371 Self::InvalidState => "invalid_state",
372 Self::ManagementCall => "management_call",
373 Self::MissingChunk => "missing_chunk",
374 Self::MissingManifest => "missing_manifest",
375 Self::Ok => "ok",
376 Self::StoreCall => "store_call",
377 Self::UnsupportedInline => "unsupported_inline",
378 }
379 }
380}
381
382#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
389#[remain::sorted]
390pub enum ManagementCallMetricOperation {
391 CanisterStatus,
392 ClearChunkStore,
393 CreateCanister,
394 DeleteCanister,
395 DepositCycles,
396 EcdsaPublicKey,
397 GetCycles,
398 InstallChunkedCode,
399 InstallCode,
400 LoadCanisterSnapshot,
401 RawRand,
402 SignWithEcdsa,
403 StopCanister,
404 StoredChunks,
405 TakeCanisterSnapshot,
406 UninstallCode,
407 UpdateSettings,
408 UploadChunk,
409}
410
411#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
418#[remain::sorted]
419pub enum ManagementCallMetricOutcome {
420 Completed,
421 Failed,
422 Started,
423}
424
425#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
432#[remain::sorted]
433pub enum ManagementCallMetricReason {
434 Infra,
435 Ok,
436}
437
438#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
445#[remain::sorted]
446pub enum PlatformCallMetricSurface {
447 Generic,
448 Http,
449 Ledger,
450 Management,
451}
452
453impl PlatformCallMetricSurface {
454 #[must_use]
456 pub const fn metric_label(self) -> &'static str {
457 match self {
458 Self::Generic => "generic",
459 Self::Http => "http",
460 Self::Ledger => "ledger",
461 Self::Management => "management",
462 }
463 }
464}
465
466#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
473#[remain::sorted]
474pub enum PlatformCallMetricMode {
475 BoundedWait,
476 UnboundedWait,
477 Update,
478}
479
480impl PlatformCallMetricMode {
481 #[must_use]
483 pub const fn metric_label(self) -> &'static str {
484 match self {
485 Self::BoundedWait => "bounded_wait",
486 Self::UnboundedWait => "unbounded_wait",
487 Self::Update => "update",
488 }
489 }
490}
491
492#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
499#[remain::sorted]
500pub enum PlatformCallMetricOutcome {
501 Completed,
502 Failed,
503 Started,
504}
505
506impl PlatformCallMetricOutcome {
507 #[must_use]
509 pub const fn metric_label(self) -> &'static str {
510 match self {
511 Self::Completed => "completed",
512 Self::Failed => "failed",
513 Self::Started => "started",
514 }
515 }
516}
517
518#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
525#[remain::sorted]
526pub enum PlatformCallMetricReason {
527 CandidDecode,
528 CandidEncode,
529 HttpStatus,
530 Infra,
531 LedgerRejected,
532 Ok,
533}
534
535impl PlatformCallMetricReason {
536 #[must_use]
538 pub const fn metric_label(self) -> &'static str {
539 match self {
540 Self::CandidDecode => "candid_decode",
541 Self::CandidEncode => "candid_encode",
542 Self::HttpStatus => "http_status",
543 Self::Infra => "infra",
544 Self::LedgerRejected => "ledger_rejected",
545 Self::Ok => "ok",
546 }
547 }
548}