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 NewAllocation,
101 NotFound,
102 Ok,
103 PolicyDenied,
104 PoolReuse,
105 PoolTopup,
106 Topology,
107 Unknown,
108}
109
110impl CanisterOpsMetricReason {
111 #[must_use]
113 pub const fn metric_label(self) -> &'static str {
114 match self {
115 Self::AlreadyExists => "already_exists",
116 Self::NewAllocation => "new_allocation",
117 Self::Cycles => "cycles",
118 Self::InvalidState => "invalid_state",
119 Self::ManagementCall => "management_call",
120 Self::MissingWasm => "missing_wasm",
121 Self::NotFound => "not_found",
122 Self::Ok => "ok",
123 Self::PolicyDenied => "policy_denied",
124 Self::PoolReuse => "pool_reuse",
125 Self::PoolTopup => "pool_topup",
126 Self::Topology => "topology",
127 Self::Unknown => "unknown",
128 }
129 }
130}
131
132#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
139#[remain::sorted]
140pub enum LifecycleMetricPhase {
141 Init,
142 PostUpgrade,
143}
144
145impl LifecycleMetricPhase {
146 #[must_use]
148 pub const fn metric_label(self) -> &'static str {
149 match self {
150 Self::Init => "init",
151 Self::PostUpgrade => "post_upgrade",
152 }
153 }
154}
155
156#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
163#[remain::sorted]
164pub enum LifecycleMetricRole {
165 Nonroot,
166 Root,
167}
168
169impl LifecycleMetricRole {
170 #[must_use]
172 pub const fn metric_label(self) -> &'static str {
173 match self {
174 Self::Nonroot => "nonroot",
175 Self::Root => "root",
176 }
177 }
178}
179
180#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
187#[remain::sorted]
188pub enum LifecycleMetricStage {
189 Bootstrap,
190 Runtime,
191}
192
193impl LifecycleMetricStage {
194 #[must_use]
196 pub const fn metric_label(self) -> &'static str {
197 match self {
198 Self::Bootstrap => "bootstrap",
199 Self::Runtime => "runtime",
200 }
201 }
202}
203
204#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
211#[remain::sorted]
212pub enum LifecycleMetricOutcome {
213 Completed,
214 Failed,
215 Scheduled,
216 Skipped,
217 Started,
218 Waiting,
219}
220
221impl LifecycleMetricOutcome {
222 #[must_use]
224 pub const fn metric_label(self) -> &'static str {
225 match self {
226 Self::Completed => "completed",
227 Self::Failed => "failed",
228 Self::Scheduled => "scheduled",
229 Self::Skipped => "skipped",
230 Self::Started => "started",
231 Self::Waiting => "waiting",
232 }
233 }
234}
235
236#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
243#[remain::sorted]
244pub enum WasmStoreMetricOperation {
245 BootstrapChunkSync,
246 ChunkPublish,
247 ChunkUpload,
248 ManifestPromote,
249 Prepare,
250 ReleasePublish,
251 SourceResolve,
252}
253
254impl WasmStoreMetricOperation {
255 #[must_use]
257 pub const fn metric_label(self) -> &'static str {
258 match self {
259 Self::BootstrapChunkSync => "bootstrap_chunk_sync",
260 Self::ChunkPublish => "chunk_publish",
261 Self::ChunkUpload => "chunk_upload",
262 Self::ManifestPromote => "manifest_promote",
263 Self::Prepare => "prepare",
264 Self::ReleasePublish => "release_publish",
265 Self::SourceResolve => "source_resolve",
266 }
267 }
268}
269
270#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
277#[remain::sorted]
278pub enum WasmStoreMetricSource {
279 Bootstrap,
280 Embedded,
281 ManagedFleet,
282 Resolver,
283 Store,
284 TargetStore,
285}
286
287impl WasmStoreMetricSource {
288 #[must_use]
290 pub const fn metric_label(self) -> &'static str {
291 match self {
292 Self::Bootstrap => "bootstrap",
293 Self::Embedded => "embedded",
294 Self::ManagedFleet => "managed_fleet",
295 Self::Resolver => "resolver",
296 Self::Store => "store",
297 Self::TargetStore => "target_store",
298 }
299 }
300}
301
302#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
309#[remain::sorted]
310pub enum WasmStoreMetricOutcome {
311 Completed,
312 Failed,
313 Skipped,
314 Started,
315}
316
317impl WasmStoreMetricOutcome {
318 #[must_use]
320 pub const fn metric_label(self) -> &'static str {
321 match self {
322 Self::Completed => "completed",
323 Self::Failed => "failed",
324 Self::Skipped => "skipped",
325 Self::Started => "started",
326 }
327 }
328}
329
330#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
337#[remain::sorted]
338pub enum WasmStoreMetricReason {
339 CacheHit,
340 CacheMiss,
341 Capacity,
342 HashMismatch,
343 InvalidState,
344 ManagementCall,
345 MissingChunk,
346 MissingManifest,
347 Ok,
348 StoreCall,
349 UnsupportedInline,
350}
351
352impl WasmStoreMetricReason {
353 #[must_use]
355 pub const fn metric_label(self) -> &'static str {
356 match self {
357 Self::CacheHit => "cache_hit",
358 Self::CacheMiss => "cache_miss",
359 Self::Capacity => "capacity",
360 Self::HashMismatch => "hash_mismatch",
361 Self::InvalidState => "invalid_state",
362 Self::ManagementCall => "management_call",
363 Self::MissingChunk => "missing_chunk",
364 Self::MissingManifest => "missing_manifest",
365 Self::Ok => "ok",
366 Self::StoreCall => "store_call",
367 Self::UnsupportedInline => "unsupported_inline",
368 }
369 }
370}
371
372#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
379#[remain::sorted]
380pub enum ManagementCallMetricOperation {
381 CanisterStatus,
382 ClearChunkStore,
383 CreateCanister,
384 DeleteCanister,
385 DepositCycles,
386 EcdsaPublicKey,
387 GetCycles,
388 InstallChunkedCode,
389 InstallCode,
390 SignWithEcdsa,
391 StopCanister,
392 StoredChunks,
393 UninstallCode,
394 UpdateSettings,
395 UploadChunk,
396}
397
398#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
405#[remain::sorted]
406pub enum ManagementCallMetricOutcome {
407 Completed,
408 Failed,
409 Started,
410}
411
412#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
419#[remain::sorted]
420pub enum ManagementCallMetricReason {
421 Infra,
422 Ok,
423}
424
425#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
432#[remain::sorted]
433pub enum PlatformCallMetricSurface {
434 Generic,
435 Management,
436}
437
438impl PlatformCallMetricSurface {
439 #[must_use]
441 pub const fn metric_label(self) -> &'static str {
442 match self {
443 Self::Generic => "generic",
444 Self::Management => "management",
445 }
446 }
447}
448
449#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
456#[remain::sorted]
457pub enum PlatformCallMetricMode {
458 BoundedWait,
459 UnboundedWait,
460 Update,
461}
462
463impl PlatformCallMetricMode {
464 #[must_use]
466 pub const fn metric_label(self) -> &'static str {
467 match self {
468 Self::BoundedWait => "bounded_wait",
469 Self::UnboundedWait => "unbounded_wait",
470 Self::Update => "update",
471 }
472 }
473}
474
475#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
482#[remain::sorted]
483pub enum PlatformCallMetricOutcome {
484 Completed,
485 Failed,
486 Started,
487}
488
489impl PlatformCallMetricOutcome {
490 #[must_use]
492 pub const fn metric_label(self) -> &'static str {
493 match self {
494 Self::Completed => "completed",
495 Self::Failed => "failed",
496 Self::Started => "started",
497 }
498 }
499}
500
501#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
508#[remain::sorted]
509pub enum PlatformCallMetricReason {
510 CandidDecode,
511 CandidEncode,
512 Infra,
513 Ok,
514}
515
516impl PlatformCallMetricReason {
517 #[must_use]
519 pub const fn metric_label(self) -> &'static str {
520 match self {
521 Self::CandidDecode => "candid_decode",
522 Self::CandidEncode => "candid_encode",
523 Self::Infra => "infra",
524 Self::Ok => "ok",
525 }
526 }
527}