Skip to main content

autopush_common/
metric_name.rs

1//! Defines standard metric names used across the application.
2//!
3//! This module provides a type-safe way to refer to metrics by replacing
4//! string literals with enum variants, ensuring consistency and discoverability.
5
6use strum::{AsRefStr, Display, EnumString};
7use strum_macros::IntoStaticStr;
8
9/// Represents all metric names used in the application.
10#[derive(Debug, Clone, IntoStaticStr, AsRefStr, Display, EnumString)]
11#[strum(serialize_all = "snake_case")]
12pub enum MetricName {
13    //
14    // User agent metrics
15    //
16    /// User agent is already connected
17    #[strum(serialize = "ua.already_connected")]
18    UaAlreadyConnected,
19
20    /// User agent hello command
21    #[strum(serialize = "ua.command.hello")]
22    UaCommandHello,
23
24    /// User agent register command
25    #[strum(serialize = "ua.command.register")]
26    UaCommandRegister,
27
28    /// User agent unregister command
29    #[strum(serialize = "ua.command.unregister")]
30    UaCommandUnregister,
31
32    /// User agent ack command
33    #[strum(serialize = "ua.command.ack")]
34    UaCommandAck,
35
36    /// User agent nack command
37    #[strum(serialize = "ua.command.nack")]
38    UaCommandNack,
39
40    /// User agent connection check
41    #[strum(serialize = "ua.connection.check")]
42    UaConnectionCheck,
43
44    /// User agent connection channel count
45    #[strum(serialize = "ua.connection.channel_count")]
46    UaConnectionChannelCount,
47
48    /// User agent notification sent
49    #[strum(serialize = "ua.notification.sent")]
50    UaNotificationSent,
51
52    /// User agent expiration
53    #[strum(serialize = "ua.expiration")]
54    UaExpiration,
55
56    //
57    // Notification metrics
58    //
59    #[strum(serialize = "notification.received")]
60    NotificationReceived,
61
62    /// Notification authentication
63    #[strum(serialize = "notification.auth")]
64    NotificationAuth,
65
66    /// Notification authentication bad VAPID JSON
67    #[strum(serialize = "notification.auth.bad_vapid.json")]
68    NotificationAuthBadVapidJson,
69
70    /// Notification authentication bad VAPID other
71    #[strum(serialize = "notification.auth.bad_vapid.other")]
72    NotificationAuthBadVapidOther,
73
74    /// Authentication success
75    #[strum(serialize = "notification.auth.ok")]
76    NotificationAuthOk,
77
78    /// Authentication error
79    #[strum(serialize = "notification.auth.error")]
80    NotificationAuthError,
81
82    /// Notification message expired
83    /// Notification had TTL=0 and was undeliverable
84    /// (i.e. no live client) so it was discarded
85    #[strum(serialize = "notification.message.expired")]
86    NotificationMessageExpired,
87
88    /// Bridge error in notification routing
89    #[strum(serialize = "notification.bridge.error")]
90    NotificationBridgeError,
91
92    /// Bridge successfully sent notification
93    #[strum(serialize = "notification.bridge.sent")]
94    NotificationBridgeSent,
95
96    /// Notification total request time
97    #[strum(serialize = "notification.total_request_time")]
98    NotificationTotalRequestTime,
99
100    /// Notification message data
101    #[strum(serialize = "notification.message_data")]
102    NotificationMessageData,
103
104    /// Notifcation message stored
105    #[strum(serialize = "notification.message.stored")]
106    NotificationMessageStored,
107
108    /// Notifcation message deleted
109    #[strum(serialize = "notification.message.deleted")]
110    NotificationMessageDeleted,
111
112    /// Time a message spent in storage before being sent to a (re)connected
113    /// client, in milliseconds. Emitted at retrieval time (where the client's
114    /// user agent is known) and tagged with a low-cardinality `os`.
115    #[strum(serialize = "notification.storage.time")]
116    NotificationStorageTime,
117
118    //
119    // Error metrics
120    //
121    /// Node timeout error
122    #[strum(serialize = "error.node.timeout")]
123    ErrorNodeTimeout,
124
125    /// Node connection error
126    #[strum(serialize = "error.node.connect")]
127    ErrorNodeConnect,
128
129    /// Disconnect semaphore full, unacked direct notifications dropped
130    #[strum(serialize = "error.disconnect.semaphore_full")]
131    ErrorDisconnectSemaphoreFull,
132
133    //
134    // Update metrics
135    //
136    /// Updates drop user
137    #[strum(serialize = "updates.drop_user")]
138    UpdatesDropUser,
139
140    /// VAPID version updates
141    #[strum(serialize = "updates.vapid.draft")]
142    UpdatesVapidDraft,
143
144    /// Client host is gone
145    #[strum(serialize = "updates.client.host_gone")]
146    UpdatesClientHostGone,
147
148    /// VAPID update
149    #[strum(serialize = "updates.vapid")]
150    UpdatesVapid,
151
152    //
153    // Megaphone metrics
154    //
155    /// Megaphone updater successful
156    #[strum(serialize = "megaphone.updater.ok")]
157    MegaphoneUpdaterOk,
158
159    /// Megaphone updater error
160    #[strum(serialize = "megaphone.updater.error")]
161    MegaphoneUpdaterError,
162
163    //
164    // Reliability metrics
165    //
166    /// Reliability error with Redis unavailable
167    #[strum(serialize = "reliability.error.redis_unavailable")]
168    ReliabilityErrorRedisUnavailable,
169
170    //
171    // Redis metrics
172    //
173    #[strum(serialize = "error.redis.unavailable")]
174    ErrorRedisUnavailable,
175
176    //
177    // Database metrics
178    //
179    // Database metric for retrying the connection
180    #[strum(serialize = "database.retry")]
181    DatabaseRetry,
182
183    // Database metric for dropping user
184    #[strum(serialize = "database.drop_user")]
185    DatabaseDropUser,
186
187    //
188    // Reliability metrics
189    //
190    // Reliability gc
191    #[strum(serialize = "reliability.gc")]
192    ReliabilityGc,
193
194    //
195    // Performance / pool metrics
196    //
197    /// Gauge of in-flight HTTP requests to autoconnect nodes
198    #[strum(serialize = "request.in_flight")]
199    InFlightNodeRequests,
200
201    /// Timer for the full notification routing path
202    #[strum(serialize = "notification.route_time")]
203    NotificationRouteTime,
204
205    /// Timer for db.save_message calls
206    #[strum(serialize = "notification.storage.save_time")]
207    StorageSaveTime,
208
209    /// Timer for the send_notification HTTP call to a node
210    #[strum(serialize = "notification.direct.delivery_time")]
211    DirectDeliveryTime,
212
213    /// Counter tagged with response status for direct delivery
214    #[strum(serialize = "notification.direct.delivery_status")]
215    DirectDeliveryStatus,
216}