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 CanisterStatus,
376 ClearChunkStore,
377 CreateCanister,
378 DeleteCanister,
379 DepositCycles,
380 EcdsaPublicKey,
381 GetCycles,
382 InstallChunkedCode,
383 InstallCode,
384 SignWithEcdsa,
385 StopCanister,
386 StoredChunks,
387 UninstallCode,
388 UpdateSettings,
389 UploadChunk,
390}
391
392#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
399#[remain::sorted]
400pub enum ManagementCallMetricOutcome {
401 Completed,
402 Failed,
403 Started,
404}
405
406#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
413#[remain::sorted]
414pub enum ManagementCallMetricReason {
415 Infra,
416 Ok,
417}
418
419#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
426#[remain::sorted]
427pub enum PlatformCallMetricSurface {
428 Generic,
429 Management,
430}
431
432impl PlatformCallMetricSurface {
433 #[must_use]
435 pub const fn metric_label(self) -> &'static str {
436 match self {
437 Self::Generic => "generic",
438 Self::Management => "management",
439 }
440 }
441}
442
443#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
450#[remain::sorted]
451pub enum PlatformCallMetricMode {
452 BoundedWait,
453 UnboundedWait,
454 Update,
455}
456
457impl PlatformCallMetricMode {
458 #[must_use]
460 pub const fn metric_label(self) -> &'static str {
461 match self {
462 Self::BoundedWait => "bounded_wait",
463 Self::UnboundedWait => "unbounded_wait",
464 Self::Update => "update",
465 }
466 }
467}
468
469#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
476#[remain::sorted]
477pub enum PlatformCallMetricOutcome {
478 Completed,
479 Failed,
480 Started,
481}
482
483impl PlatformCallMetricOutcome {
484 #[must_use]
486 pub const fn metric_label(self) -> &'static str {
487 match self {
488 Self::Completed => "completed",
489 Self::Failed => "failed",
490 Self::Started => "started",
491 }
492 }
493}
494
495#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
502#[remain::sorted]
503pub enum PlatformCallMetricReason {
504 CandidDecode,
505 CandidEncode,
506 Infra,
507 Ok,
508}
509
510impl PlatformCallMetricReason {
511 #[must_use]
513 pub const fn metric_label(self) -> &'static str {
514 match self {
515 Self::CandidDecode => "candid_decode",
516 Self::CandidEncode => "candid_encode",
517 Self::Infra => "infra",
518 Self::Ok => "ok",
519 }
520 }
521}