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    /// User agent command with dynamic command name
14    #[strum(serialize = "ua.command")]
15    UaCommand(String),
16    //
17    // User agent metrics
18    //
19    /// User agent is already connected
20    #[strum(serialize = "ua.already_connected")]
21    UaAlreadyConnected,
22
23    /// User agent register command
24    #[strum(serialize = "ua.command.register")]
25    UaCommandRegister,
26
27    /// User agent unregister command
28    #[strum(serialize = "ua.command.unregister")]
29    UaCommandUnregister,
30
31    /// User agent connection check
32    #[strum(serialize = "ua.connection.check")]
33    UaConnectionCheck,
34
35    /// User agent connection channel count
36    #[strum(serialize = "ua.connection.channel_count")]
37    UaConnectionChannelCount,
38
39    /// User agent notification sent
40    #[strum(serialize = "ua.notification.sent")]
41    UaNotificationSent,
42
43    /// User agent expiration
44    #[strum(serialize = "ua.expiration")]
45    UaExpiration,
46
47    //
48    // Notification metrics
49    //
50    /// Notification authentication
51    #[strum(serialize = "notification.auth")]
52    NotificationAuth,
53
54    /// Notification authentication bad VAPID JSON
55    #[strum(serialize = "notification.auth.bad_vapid.json")]
56    NotificationAuthBadVapidJson,
57
58    /// Notification authentication bad VAPID other
59    #[strum(serialize = "notification.auth.bad_vapid.other")]
60    NotificationAuthBadVapidOther,
61
62    /// Authentication success
63    #[strum(serialize = "notification.auth.ok")]
64    NotificationAuthOk,
65
66    /// Authentication error
67    #[strum(serialize = "notification.auth.error")]
68    NotificationAuthError,
69
70    /// Notification message expired
71    #[strum(serialize = "notification.message.expired")]
72    NotificationMessageExpired,
73
74    /// Bridge error in notification routing
75    #[strum(serialize = "notification.bridge.error")]
76    NotificationBridgeError,
77
78    /// Bridge successfully sent notification
79    #[strum(serialize = "notification.bridge.sent")]
80    NotificationBridgeSent,
81
82    /// Notification total request time
83    #[strum(serialize = "notification.total_request_time")]
84    NotificationTotalRequestTime,
85
86    /// Notification message data
87    #[strum(serialize = "notification.message_data")]
88    NotificationMessageData,
89
90    /// Notifcation message stored
91    #[strum(serialize = "notification.message.stored")]
92    NotificationMessageStored,
93
94    /// Notifcation message deleted
95    #[strum(serialize = "notification.message.deleted")]
96    NotificationMessageDeleted,
97
98    //
99    // Error metrics
100    //
101    /// Node timeout error
102    #[strum(serialize = "error.node.timeout")]
103    ErrorNodeTimeout,
104
105    /// Node connection error
106    #[strum(serialize = "error.node.connect")]
107    ErrorNodeConnect,
108
109    //
110    // Update metrics
111    //
112    /// Updates drop user
113    #[strum(serialize = "updates.drop_user")]
114    UpdatesDropUser,
115
116    /// VAPID version updates
117    #[strum(serialize = "updates.vapid.draft")]
118    UpdatesVapidDraft,
119
120    /// Client host is gone
121    #[strum(serialize = "updates.client.host_gone")]
122    UpdatesClientHostGone,
123
124    /// VAPID update
125    #[strum(serialize = "updates.vapid")]
126    UpdatesVapid,
127
128    //
129    // Megaphone metrics
130    //
131    /// Megaphone updater successful
132    #[strum(serialize = "megaphone.updater.ok")]
133    MegaphoneUpdaterOk,
134
135    /// Megaphone updater error
136    #[strum(serialize = "megaphone.updater.error")]
137    MegaphoneUpdaterError,
138
139    //
140    // Reliability metrics
141    //
142    /// Reliability error with Redis unavailable
143    #[strum(serialize = "reliability.error.redis_unavailable")]
144    ReliabilityErrorRedisUnavailable,
145
146    //
147    // Redis metrics
148    //
149    #[strum(serialize = "error.redis.unavailable")]
150    ErrorRedisUnavailable,
151
152    //
153    // Database metrics
154    //
155    // Database metric for retrying the connection
156    #[strum(serialize = "database.retry")]
157    DatabaseRetry,
158
159    // Database metric for dropping user
160    #[strum(serialize = "database.drop_user")]
161    DatabaseDropUser,
162
163    //
164    // Reliability metrics
165    //
166    // Reliability gc
167    #[strum(serialize = "reliability.gc")]
168    ReliabilityGc,
169}