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 ManagedFleet,
275 Resolver,
276 Store,
277 TargetStore,
278}
279
280impl WasmStoreMetricSource {
281 #[must_use]
283 pub const fn metric_label(self) -> &'static str {
284 match self {
285 Self::Bootstrap => "bootstrap",
286 Self::ManagedFleet => "managed_fleet",
287 Self::Resolver => "resolver",
288 Self::Store => "store",
289 Self::TargetStore => "target_store",
290 }
291 }
292}
293
294#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
301#[remain::sorted]
302pub enum WasmStoreMetricOutcome {
303 Completed,
304 Failed,
305 Skipped,
306 Started,
307}
308
309impl WasmStoreMetricOutcome {
310 #[must_use]
312 pub const fn metric_label(self) -> &'static str {
313 match self {
314 Self::Completed => "completed",
315 Self::Failed => "failed",
316 Self::Skipped => "skipped",
317 Self::Started => "started",
318 }
319 }
320}
321
322#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
329#[remain::sorted]
330pub enum WasmStoreMetricReason {
331 CacheHit,
332 CacheMiss,
333 Capacity,
334 HashMismatch,
335 InvalidState,
336 ManagementCall,
337 MissingChunk,
338 MissingManifest,
339 Ok,
340 StoreCall,
341 UnsupportedInline,
342}
343
344impl WasmStoreMetricReason {
345 #[must_use]
347 pub const fn metric_label(self) -> &'static str {
348 match self {
349 Self::CacheHit => "cache_hit",
350 Self::CacheMiss => "cache_miss",
351 Self::Capacity => "capacity",
352 Self::HashMismatch => "hash_mismatch",
353 Self::InvalidState => "invalid_state",
354 Self::ManagementCall => "management_call",
355 Self::MissingChunk => "missing_chunk",
356 Self::MissingManifest => "missing_manifest",
357 Self::Ok => "ok",
358 Self::StoreCall => "store_call",
359 Self::UnsupportedInline => "unsupported_inline",
360 }
361 }
362}
363
364#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
371#[remain::sorted]
372pub enum ManagementCallMetricOperation {
373 CanisterInfo,
374 CanisterStatus,
375 ClearChunkStore,
376 DeleteCanister,
377 DepositCycles,
378 EcdsaPublicKey,
379 GetCycles,
380 InstallChunkedCode,
381 InstallCode,
382 SignWithEcdsa,
383 StopCanister,
384 StoredChunks,
385 UninstallCode,
386 UpdateSettings,
387 UploadChunk,
388}
389
390#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
397#[remain::sorted]
398pub enum ManagementCallMetricOutcome {
399 Completed,
400 Failed,
401 Started,
402}
403
404#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
411#[remain::sorted]
412pub enum ManagementCallMetricReason {
413 Infra,
414 Ok,
415}
416
417#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
424#[remain::sorted]
425pub enum PlatformCallMetricSurface {
426 Generic,
427 Management,
428}
429
430impl PlatformCallMetricSurface {
431 #[must_use]
433 pub const fn metric_label(self) -> &'static str {
434 match self {
435 Self::Generic => "generic",
436 Self::Management => "management",
437 }
438 }
439}
440
441#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
448#[remain::sorted]
449pub enum PlatformCallMetricMode {
450 BoundedWait,
451 UnboundedWait,
452 Update,
453}
454
455impl PlatformCallMetricMode {
456 #[must_use]
458 pub const fn metric_label(self) -> &'static str {
459 match self {
460 Self::BoundedWait => "bounded_wait",
461 Self::UnboundedWait => "unbounded_wait",
462 Self::Update => "update",
463 }
464 }
465}
466
467#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
474#[remain::sorted]
475pub enum PlatformCallMetricOutcome {
476 Completed,
477 Failed,
478 Started,
479}
480
481impl PlatformCallMetricOutcome {
482 #[must_use]
484 pub const fn metric_label(self) -> &'static str {
485 match self {
486 Self::Completed => "completed",
487 Self::Failed => "failed",
488 Self::Started => "started",
489 }
490 }
491}
492
493#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
500#[remain::sorted]
501pub enum PlatformCallMetricReason {
502 CandidDecode,
503 CandidEncode,
504 Infra,
505 Ok,
506}
507
508impl PlatformCallMetricReason {
509 #[must_use]
511 pub const fn metric_label(self) -> &'static str {
512 match self {
513 Self::CandidDecode => "candid_decode",
514 Self::CandidEncode => "candid_encode",
515 Self::Infra => "infra",
516 Self::Ok => "ok",
517 }
518 }
519}