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    #[strum(serialize = "notification.message.expired")]
84    NotificationMessageExpired,
85
86    /// Bridge error in notification routing
87    #[strum(serialize = "notification.bridge.error")]
88    NotificationBridgeError,
89
90    /// Bridge successfully sent notification
91    #[strum(serialize = "notification.bridge.sent")]
92    NotificationBridgeSent,
93
94    /// Notification total request time
95    #[strum(serialize = "notification.total_request_time")]
96    NotificationTotalRequestTime,
97
98    /// Notification message data
99    #[strum(serialize = "notification.message_data")]
100    NotificationMessageData,
101
102    /// Notifcation message stored
103    #[strum(serialize = "notification.message.stored")]
104    NotificationMessageStored,
105
106    /// Notifcation message deleted
107    #[strum(serialize = "notification.message.deleted")]
108    NotificationMessageDeleted,
109
110    //
111    // Error metrics
112    //
113    /// Node timeout error
114    #[strum(serialize = "error.node.timeout")]
115    ErrorNodeTimeout,
116
117    /// Node connection error
118    #[strum(serialize = "error.node.connect")]
119    ErrorNodeConnect,
120
121    /// Disconnect semaphore full, unacked direct notifications dropped
122    #[strum(serialize = "error.disconnect.semaphore_full")]
123    ErrorDisconnectSemaphoreFull,
124
125    //
126    // Update metrics
127    //
128    /// Updates drop user
129    #[strum(serialize = "updates.drop_user")]
130    UpdatesDropUser,
131
132    /// VAPID version updates
133    #[strum(serialize = "updates.vapid.draft")]
134    UpdatesVapidDraft,
135
136    /// Client host is gone
137    #[strum(serialize = "updates.client.host_gone")]
138    UpdatesClientHostGone,
139
140    /// VAPID update
141    #[strum(serialize = "updates.vapid")]
142    UpdatesVapid,
143
144    //
145    // Megaphone metrics
146    //
147    /// Megaphone updater successful
148    #[strum(serialize = "megaphone.updater.ok")]
149    MegaphoneUpdaterOk,
150
151    /// Megaphone updater error
152    #[strum(serialize = "megaphone.updater.error")]
153    MegaphoneUpdaterError,
154
155    //
156    // Reliability metrics
157    //
158    /// Reliability error with Redis unavailable
159    #[strum(serialize = "reliability.error.redis_unavailable")]
160    ReliabilityErrorRedisUnavailable,
161
162    //
163    // Redis metrics
164    //
165    #[strum(serialize = "error.redis.unavailable")]
166    ErrorRedisUnavailable,
167
168    //
169    // Database metrics
170    //
171    // Database metric for retrying the connection
172    #[strum(serialize = "database.retry")]
173    DatabaseRetry,
174
175    // Database metric for dropping user
176    #[strum(serialize = "database.drop_user")]
177    DatabaseDropUser,
178
179    //
180    // Reliability metrics
181    //
182    // Reliability gc
183    #[strum(serialize = "reliability.gc")]
184    ReliabilityGc,
185
186    //
187    // Performance / pool metrics
188    //
189    /// Gauge of in-flight HTTP requests to autoconnect nodes
190    #[strum(serialize = "request.in_flight")]
191    InFlightNodeRequests,
192
193    /// Timer for the full notification routing path
194    #[strum(serialize = "notification.route_time")]
195    NotificationRouteTime,
196
197    /// Timer for db.save_message calls
198    #[strum(serialize = "notification.storage.save_time")]
199    StorageSaveTime,
200
201    /// Timer for the send_notification HTTP call to a node
202    #[strum(serialize = "notification.direct.delivery_time")]
203    DirectDeliveryTime,
204
205    /// Counter tagged with response status for direct delivery
206    #[strum(serialize = "notification.direct.delivery_status")]
207    DirectDeliveryStatus,
208}