canic_core/dto/
metrics.rs

1use crate::{dto::prelude::*, ids::AccessMetricKind};
2
3///
4/// AccessMetricEntry
5/// Snapshot entry pairing an endpoint/stage with its count.
6///
7
8#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
9pub struct AccessMetricEntry {
10    pub endpoint: String,
11    pub kind: AccessMetricKind,
12    pub count: u64,
13}
14
15///
16/// EndpointAttemptMetricEntry
17/// Public metric entry for endpoint attempt/completion.
18///
19#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
20pub struct EndpointAttemptMetricEntry {
21    pub endpoint: String,
22    pub attempted: u64,
23    pub completed: u64,
24}
25
26///
27/// EndpointResultMetricEntry
28/// Public metric entry for endpoint ok/err outcomes.
29///
30#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
31pub struct EndpointResultMetricEntry {
32    pub endpoint: String,
33    pub ok: u64,
34    pub err: u64,
35}
36
37///
38/// EndpointHealthView
39/// Derived endpoint-level health view joined at read time.
40///
41
42#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
43pub struct EndpointHealthView {
44    pub endpoint: String,
45    pub attempted: u64,
46    pub denied: u64,
47    pub completed: u64,
48    pub ok: u64,
49    pub err: u64,
50}
51
52///
53/// HttpMetricEntry
54/// Snapshot entry pairing a method/label with its count.
55///
56
57#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
58pub struct HttpMetricEntry {
59    pub method: String,
60    pub label: String,
61    pub count: u64,
62}
63
64///
65/// IccMetricEntry
66///
67
68#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
69pub struct IccMetricEntry {
70    pub target: Principal,
71    pub method: String,
72    pub count: u64,
73}
74
75///
76/// SystemMetricEntry
77///
78
79#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
80pub struct SystemMetricEntry {
81    pub kind: String,
82    pub count: u64,
83}
84
85///
86/// TimerMetricEntry
87///
88
89#[derive(CandidType, Clone, Debug, Deserialize, Serialize)]
90pub struct TimerMetricEntry {
91    pub mode: String,
92    pub delay_ms: u64,
93    pub label: String,
94    pub count: u64,
95}