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}
44
45impl CanisterOpsMetricOperation {
46 #[must_use]
48 pub const fn metric_label(self) -> &'static str {
49 match self {
50 Self::Create => "create",
51 Self::Delete => "delete",
52 Self::Install => "install",
53 Self::Reinstall => "reinstall",
54 }
55 }
56}
57
58#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
65#[remain::sorted]
66pub enum CanisterOpsMetricOutcome {
67 Completed,
68 Failed,
69 Skipped,
70 Started,
71}
72
73impl CanisterOpsMetricOutcome {
74 #[must_use]
76 pub const fn metric_label(self) -> &'static str {
77 match self {
78 Self::Completed => "completed",
79 Self::Failed => "failed",
80 Self::Skipped => "skipped",
81 Self::Started => "started",
82 }
83 }
84}
85
86#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
93#[remain::sorted]
94pub enum CanisterOpsMetricReason {
95 AlreadyExists,
96 Cycles,
97 InvalidState,
98 ManagementCall,
99 MissingWasm,
100 NotFound,
101 Ok,
102 PolicyDenied,
103 Topology,
104 Unknown,
105}
106
107impl CanisterOpsMetricReason {
108 #[must_use]
110 pub const fn metric_label(self) -> &'static str {
111 match self {
112 Self::AlreadyExists => "already_exists",
113 Self::Cycles => "cycles",
114 Self::InvalidState => "invalid_state",
115 Self::ManagementCall => "management_call",
116 Self::MissingWasm => "missing_wasm",
117 Self::NotFound => "not_found",
118 Self::Ok => "ok",
119 Self::PolicyDenied => "policy_denied",
120 Self::Topology => "topology",
121 Self::Unknown => "unknown",
122 }
123 }
124}
125
126#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
133#[remain::sorted]
134pub enum LifecycleMetricPhase {
135 Init,
136 PostUpgrade,
137}
138
139impl LifecycleMetricPhase {
140 #[must_use]
142 pub const fn metric_label(self) -> &'static str {
143 match self {
144 Self::Init => "init",
145 Self::PostUpgrade => "post_upgrade",
146 }
147 }
148}
149
150#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
157#[remain::sorted]
158pub enum LifecycleMetricRole {
159 Nonroot,
160 Root,
161}
162
163impl LifecycleMetricRole {
164 #[must_use]
166 pub const fn metric_label(self) -> &'static str {
167 match self {
168 Self::Nonroot => "nonroot",
169 Self::Root => "root",
170 }
171 }
172}
173
174#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
181#[remain::sorted]
182pub enum LifecycleMetricStage {
183 Bootstrap,
184 Runtime,
185}
186
187impl LifecycleMetricStage {
188 #[must_use]
190 pub const fn metric_label(self) -> &'static str {
191 match self {
192 Self::Bootstrap => "bootstrap",
193 Self::Runtime => "runtime",
194 }
195 }
196}
197
198#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
205#[remain::sorted]
206pub enum LifecycleMetricOutcome {
207 Completed,
208 Failed,
209 Scheduled,
210 Skipped,
211 Started,
212 Waiting,
213}
214
215impl LifecycleMetricOutcome {
216 #[must_use]
218 pub const fn metric_label(self) -> &'static str {
219 match self {
220 Self::Completed => "completed",
221 Self::Failed => "failed",
222 Self::Scheduled => "scheduled",
223 Self::Skipped => "skipped",
224 Self::Started => "started",
225 Self::Waiting => "waiting",
226 }
227 }
228}
229
230#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
237#[remain::sorted]
238pub enum WasmStoreMetricOperation {
239 BootstrapChunkSync,
240 ChunkPublish,
241 ChunkUpload,
242 ManifestPromote,
243 Prepare,
244 ReleasePublish,
245 SourceResolve,
246}
247
248impl WasmStoreMetricOperation {
249 #[must_use]
251 pub const fn metric_label(self) -> &'static str {
252 match self {
253 Self::BootstrapChunkSync => "bootstrap_chunk_sync",
254 Self::ChunkPublish => "chunk_publish",
255 Self::ChunkUpload => "chunk_upload",
256 Self::ManifestPromote => "manifest_promote",
257 Self::Prepare => "prepare",
258 Self::ReleasePublish => "release_publish",
259 Self::SourceResolve => "source_resolve",
260 }
261 }
262}
263
264#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
271#[remain::sorted]
272pub enum WasmStoreMetricSource {
273 Bootstrap,
274 Embedded,
275 ManagedFleet,
276 Resolver,
277 Store,
278 TargetStore,
279}
280
281impl WasmStoreMetricSource {
282 #[must_use]
284 pub const fn metric_label(self) -> &'static str {
285 match self {
286 Self::Bootstrap => "bootstrap",
287 Self::Embedded => "embedded",
288 Self::ManagedFleet => "managed_fleet",
289 Self::Resolver => "resolver",
290 Self::Store => "store",
291 Self::TargetStore => "target_store",
292 }
293 }
294}
295
296#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
303#[remain::sorted]
304pub enum WasmStoreMetricOutcome {
305 Completed,
306 Failed,
307 Skipped,
308 Started,
309}
310
311impl WasmStoreMetricOutcome {
312 #[must_use]
314 pub const fn metric_label(self) -> &'static str {
315 match self {
316 Self::Completed => "completed",
317 Self::Failed => "failed",
318 Self::Skipped => "skipped",
319 Self::Started => "started",
320 }
321 }
322}
323
324#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
331#[remain::sorted]
332pub enum WasmStoreMetricReason {
333 CacheHit,
334 CacheMiss,
335 Capacity,
336 HashMismatch,
337 InvalidState,
338 ManagementCall,
339 MissingChunk,
340 MissingManifest,
341 Ok,
342 StoreCall,
343 UnsupportedInline,
344}
345
346impl WasmStoreMetricReason {
347 #[must_use]
349 pub const fn metric_label(self) -> &'static str {
350 match self {
351 Self::CacheHit => "cache_hit",
352 Self::CacheMiss => "cache_miss",
353 Self::Capacity => "capacity",
354 Self::HashMismatch => "hash_mismatch",
355 Self::InvalidState => "invalid_state",
356 Self::ManagementCall => "management_call",
357 Self::MissingChunk => "missing_chunk",
358 Self::MissingManifest => "missing_manifest",
359 Self::Ok => "ok",
360 Self::StoreCall => "store_call",
361 Self::UnsupportedInline => "unsupported_inline",
362 }
363 }
364}
365
366#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
373#[remain::sorted]
374pub enum ManagementCallMetricOperation {
375 CanisterInfo,
376 CanisterStatus,
377 ClearChunkStore,
378 CreateCanister,
379 DeleteCanister,
380 DepositCycles,
381 EcdsaPublicKey,
382 GetCycles,
383 InstallChunkedCode,
384 InstallCode,
385 SignWithEcdsa,
386 StopCanister,
387 StoredChunks,
388 UninstallCode,
389 UpdateSettings,
390 UploadChunk,
391}
392
393#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
400#[remain::sorted]
401pub enum ManagementCallMetricOutcome {
402 Completed,
403 Failed,
404 Started,
405}
406
407#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
414#[remain::sorted]
415pub enum ManagementCallMetricReason {
416 Infra,
417 Ok,
418}
419
420#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
427#[remain::sorted]
428pub enum PlatformCallMetricSurface {
429 Generic,
430 Management,
431}
432
433impl PlatformCallMetricSurface {
434 #[must_use]
436 pub const fn metric_label(self) -> &'static str {
437 match self {
438 Self::Generic => "generic",
439 Self::Management => "management",
440 }
441 }
442}
443
444#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
451#[remain::sorted]
452pub enum PlatformCallMetricMode {
453 BoundedWait,
454 UnboundedWait,
455 Update,
456}
457
458impl PlatformCallMetricMode {
459 #[must_use]
461 pub const fn metric_label(self) -> &'static str {
462 match self {
463 Self::BoundedWait => "bounded_wait",
464 Self::UnboundedWait => "unbounded_wait",
465 Self::Update => "update",
466 }
467 }
468}
469
470#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
477#[remain::sorted]
478pub enum PlatformCallMetricOutcome {
479 Completed,
480 Failed,
481 Started,
482}
483
484impl PlatformCallMetricOutcome {
485 #[must_use]
487 pub const fn metric_label(self) -> &'static str {
488 match self {
489 Self::Completed => "completed",
490 Self::Failed => "failed",
491 Self::Started => "started",
492 }
493 }
494}
495
496#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
503#[remain::sorted]
504pub enum PlatformCallMetricReason {
505 CandidDecode,
506 CandidEncode,
507 Infra,
508 Ok,
509}
510
511impl PlatformCallMetricReason {
512 #[must_use]
514 pub const fn metric_label(self) -> &'static str {
515 match self {
516 Self::CandidDecode => "candid_decode",
517 Self::CandidEncode => "candid_encode",
518 Self::Infra => "infra",
519 Self::Ok => "ok",
520 }
521 }
522}