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