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    /// Notification authentication
60    #[strum(serialize = "notification.auth")]
61    NotificationAuth,
62
63    /// Notification authentication bad VAPID JSON
64    #[strum(serialize = "notification.auth.bad_vapid.json")]
65    NotificationAuthBadVapidJson,
66
67    /// Notification authentication bad VAPID other
68    #[strum(serialize = "notification.auth.bad_vapid.other")]
69    NotificationAuthBadVapidOther,
70
71    /// Authentication success
72    #[strum(serialize = "notification.auth.ok")]
73    NotificationAuthOk,
74
75    /// Authentication error
76    #[strum(serialize = "notification.auth.error")]
77    NotificationAuthError,
78
79    /// Notification message expired
80    #[strum(serialize = "notification.message.expired")]
81    NotificationMessageExpired,
82
83    /// Bridge error in notification routing
84    #[strum(serialize = "notification.bridge.error")]
85    NotificationBridgeError,
86
87    /// Bridge successfully sent notification
88    #[strum(serialize = "notification.bridge.sent")]
89    NotificationBridgeSent,
90
91    /// Notification total request time
92    #[strum(serialize = "notification.total_request_time")]
93    NotificationTotalRequestTime,
94
95    /// Notification message data
96    #[strum(serialize = "notification.message_data")]
97    NotificationMessageData,
98
99    /// Notifcation message stored
100    #[strum(serialize = "notification.message.stored")]
101    NotificationMessageStored,
102
103    /// Notifcation message deleted
104    #[strum(serialize = "notification.message.deleted")]
105    NotificationMessageDeleted,
106
107    //
108    // Error metrics
109    //
110    /// Node timeout error
111    #[strum(serialize = "error.node.timeout")]
112    ErrorNodeTimeout,
113
114    /// Node connection error
115    #[strum(serialize = "error.node.connect")]
116    ErrorNodeConnect,
117
118    //
119    // Update metrics
120    //
121    /// Updates drop user
122    #[strum(serialize = "updates.drop_user")]
123    UpdatesDropUser,
124
125    /// VAPID version updates
126    #[strum(serialize = "updates.vapid.draft")]
127    UpdatesVapidDraft,
128
129    /// Client host is gone
130    #[strum(serialize = "updates.client.host_gone")]
131    UpdatesClientHostGone,
132
133    /// VAPID update
134    #[strum(serialize = "updates.vapid")]
135    UpdatesVapid,
136
137    //
138    // Megaphone metrics
139    //
140    /// Megaphone updater successful
141    #[strum(serialize = "megaphone.updater.ok")]
142    MegaphoneUpdaterOk,
143
144    /// Megaphone updater error
145    #[strum(serialize = "megaphone.updater.error")]
146    MegaphoneUpdaterError,
147
148    //
149    // Reliability metrics
150    //
151    /// Reliability error with Redis unavailable
152    #[strum(serialize = "reliability.error.redis_unavailable")]
153    ReliabilityErrorRedisUnavailable,
154
155    //
156    // Redis metrics
157    //
158    #[strum(serialize = "error.redis.unavailable")]
159    ErrorRedisUnavailable,
160
161    //
162    // Database metrics
163    //
164    // Database metric for retrying the connection
165    #[strum(serialize = "database.retry")]
166    DatabaseRetry,
167
168    // Database metric for dropping user
169    #[strum(serialize = "database.drop_user")]
170    DatabaseDropUser,
171
172    //
173    // Reliability metrics
174    //
175    // Reliability gc
176    #[strum(serialize = "reliability.gc")]
177    ReliabilityGc,
178}