Skip to main content

relay_server/
statsd.rs

1use relay_statsd::{CounterMetric, DistributionMetric, GaugeMetric, TimerMetric};
2#[cfg(doc)]
3use relay_system::RuntimeMetrics;
4
5/// Gauge metrics used by Relay
6pub enum RelayGauges {
7    /// Tracks the number of futures waiting to be executed in the pool's queue.
8    ///
9    /// Useful for understanding the backlog of work and identifying potential bottlenecks.
10    ///
11    /// This metric is tagged with:
12    /// - `pool`: the name of the pool.
13    AsyncPoolQueueSize,
14    /// Tracks the utilization of the async pool.
15    ///
16    /// The utilization is a value between 0.0 and 100.0 which determines how busy the pool is doing
17    /// CPU-bound work.
18    ///
19    /// This metric is tagged with:
20    /// - `pool`: the name of the pool.
21    AsyncPoolUtilization,
22    /// Tracks the activity of the async pool.
23    ///
24    /// The activity is a value between 0.0 and 100.0 which determines how busy is the pool
25    /// w.r.t. to its provisioned capacity.
26    ///
27    /// This metric is tagged with:
28    /// - `pool`: the name of the pool.
29    AsyncPoolActivity,
30    /// The state of Relay with respect to the upstream connection.
31    /// Possible values are `0` for normal operations and `1` for a network outage.
32    NetworkOutage,
33    /// Number of elements in the envelope buffer across all the stacks.
34    ///
35    /// This metric is tagged with:
36    /// - `storage_type`: The type of storage used in the envelope buffer.
37    BufferEnvelopesCount,
38    /// The number of individual stacks in the priority queue.
39    ///
40    /// Per combination of `(own_key, sampling_key)`, a new stack is created.
41    BufferStackCount,
42    /// The used disk for the buffer.
43    BufferDiskUsed,
44    /// The currently used memory by the entire system.
45    ///
46    /// Relay uses the same value for its memory health check.
47    SystemMemoryUsed,
48    /// The total system memory.
49    ///
50    /// Relay uses the same value for its memory health check.
51    SystemMemoryTotal,
52    /// The number of connections currently being managed by the Redis Pool.
53    #[cfg(feature = "processing")]
54    RedisPoolConnections,
55    /// The number of idle connections in the Redis Pool.
56    #[cfg(feature = "processing")]
57    RedisPoolIdleConnections,
58    /// The maximum number of connections in the Redis pool.
59    #[cfg(feature = "processing")]
60    RedisPoolMaxConnections,
61    /// The number of futures waiting to grab a connection.
62    #[cfg(feature = "processing")]
63    RedisPoolWaitingForConnection,
64    /// The number of notifications in the broadcast channel of the project cache.
65    ProjectCacheNotificationChannel,
66    /// The number of scheduled and in progress fetches in the project cache.
67    ProjectCacheScheduledFetches,
68    /// Exposes the amount of currently open and handled connections by the server.
69    ServerActiveConnections,
70    /// Maximum delay of a metric bucket in seconds.
71    ///
72    /// The maximum is measured from initial creation of the bucket in an internal Relay
73    /// until it is produced to Kafka.
74    ///
75    /// This metric is tagged with:
76    /// - `namespace`: the metric namespace.
77    #[cfg(feature = "processing")]
78    MetricDelayMax,
79    /// Estimated percentage [0-100] of how busy Relay's internal services are.
80    ///
81    /// This metric is tagged with:
82    /// - `service`: the service name.
83    /// - `instance_id`: a for the service name unique identifier for the running service
84    ServiceUtilization,
85}
86
87impl GaugeMetric for RelayGauges {
88    fn name(&self) -> &'static str {
89        match self {
90            Self::AsyncPoolQueueSize => "async_pool.queue_size",
91            Self::AsyncPoolUtilization => "async_pool.utilization",
92            Self::AsyncPoolActivity => "async_pool.activity",
93            Self::NetworkOutage => "upstream.network_outage",
94            Self::BufferEnvelopesCount => "buffer.envelopes_count.gauge",
95            Self::BufferStackCount => "buffer.stack_count",
96            Self::BufferDiskUsed => "buffer.disk_used",
97            Self::SystemMemoryUsed => "health.system_memory.used",
98            Self::SystemMemoryTotal => "health.system_memory.total",
99            #[cfg(feature = "processing")]
100            Self::RedisPoolConnections => "redis.pool.connections",
101            #[cfg(feature = "processing")]
102            Self::RedisPoolIdleConnections => "redis.pool.idle_connections",
103            #[cfg(feature = "processing")]
104            Self::RedisPoolMaxConnections => "redis.pool.max_connections",
105            #[cfg(feature = "processing")]
106            Self::RedisPoolWaitingForConnection => "redis.pool.waiting_for_connection",
107            Self::ProjectCacheNotificationChannel => "project_cache.notification_channel.size",
108            Self::ProjectCacheScheduledFetches => "project_cache.fetches.size",
109            Self::ServerActiveConnections => "server.http.connections",
110            #[cfg(feature = "processing")]
111            Self::MetricDelayMax => "metrics.delay.max",
112            Self::ServiceUtilization => "service.utilization",
113        }
114    }
115}
116
117/// Gauge metrics collected from the Runtime.
118pub enum RuntimeGauges {
119    /// Exposes [`RuntimeMetrics::num_idle_threads`].
120    NumIdleThreads,
121    /// Exposes [`RuntimeMetrics::num_alive_tasks`].
122    NumAliveTasks,
123    /// Exposes [`RuntimeMetrics::blocking_queue_depth`].
124    BlockingQueueDepth,
125    /// Exposes [`RuntimeMetrics::num_blocking_threads`].
126    NumBlockingThreads,
127    /// Exposes [`RuntimeMetrics::num_idle_blocking_threads`].
128    NumIdleBlockingThreads,
129    /// Exposes [`RuntimeMetrics::num_workers`].
130    NumWorkers,
131    /// Exposes [`RuntimeMetrics::worker_local_queue_depth`].
132    ///
133    /// This metric is tagged with:
134    /// - `worker`: the worker id.
135    WorkerLocalQueueDepth,
136    /// Exposes [`RuntimeMetrics::worker_mean_poll_time`].
137    ///
138    /// This metric is tagged with:
139    /// - `worker`: the worker id.
140    WorkerMeanPollTime,
141}
142
143impl GaugeMetric for RuntimeGauges {
144    fn name(&self) -> &'static str {
145        match self {
146            RuntimeGauges::NumIdleThreads => "runtime.idle_threads",
147            RuntimeGauges::NumAliveTasks => "runtime.alive_tasks",
148            RuntimeGauges::BlockingQueueDepth => "runtime.blocking_queue_depth",
149            RuntimeGauges::NumBlockingThreads => "runtime.num_blocking_threads",
150            RuntimeGauges::NumIdleBlockingThreads => "runtime.num_idle_blocking_threads",
151            RuntimeGauges::NumWorkers => "runtime.num_workers",
152            RuntimeGauges::WorkerLocalQueueDepth => "runtime.worker_local_queue_depth",
153            RuntimeGauges::WorkerMeanPollTime => "runtime.worker_mean_poll_time",
154        }
155    }
156}
157
158/// Counter metrics collected from the Runtime.
159pub enum RuntimeCounters {
160    /// Exposes [`RuntimeMetrics::budget_forced_yield_count`].
161    BudgetForcedYieldCount,
162    /// Exposes [`RuntimeMetrics::worker_local_schedule_count`].
163    ///
164    /// This metric is tagged with:
165    /// - `worker`: the worker id.
166    WorkerLocalScheduleCount,
167    /// Exposes [`RuntimeMetrics::worker_noop_count`].
168    ///
169    /// This metric is tagged with:
170    /// - `worker`: the worker id.
171    WorkerNoopCount,
172    /// Exposes [`RuntimeMetrics::worker_overflow_count`].
173    ///
174    /// This metric is tagged with:
175    /// - `worker`: the worker id.
176    WorkerOverflowCount,
177    /// Exposes [`RuntimeMetrics::worker_park_count`].
178    ///
179    /// This metric is tagged with:
180    /// - `worker`: the worker id.
181    WorkerParkCount,
182    /// Exposes [`RuntimeMetrics::worker_poll_count`].
183    ///
184    /// This metric is tagged with:
185    /// - `worker`: the worker id.
186    WorkerPollCount,
187    /// Exposes [`RuntimeMetrics::worker_steal_count`].
188    ///
189    /// This metric is tagged with:
190    /// - `worker`: the worker id.
191    WorkerStealCount,
192    /// Exposes [`RuntimeMetrics::worker_steal_operations`].
193    ///
194    /// This metric is tagged with:
195    /// - `worker`: the worker id.
196    WorkerStealOperations,
197    /// Exposes [`RuntimeMetrics::worker_total_busy_duration`].
198    ///
199    /// This metric is tagged with:
200    /// - `worker`: the worker id.
201    WorkerTotalBusyDuration,
202}
203
204impl CounterMetric for RuntimeCounters {
205    fn name(&self) -> &'static str {
206        match self {
207            RuntimeCounters::BudgetForcedYieldCount => "runtime.budget_forced_yield_count",
208            RuntimeCounters::WorkerLocalScheduleCount => "runtime.worker_local_schedule_count",
209            RuntimeCounters::WorkerNoopCount => "runtime.worker_noop_count",
210            RuntimeCounters::WorkerOverflowCount => "runtime.worker_overflow_count",
211            RuntimeCounters::WorkerParkCount => "runtime.worker_park_count",
212            RuntimeCounters::WorkerPollCount => "runtime.worker_poll_count",
213            RuntimeCounters::WorkerStealCount => "runtime.worker_steal_count",
214            RuntimeCounters::WorkerStealOperations => "runtime.worker_steal_operations",
215            RuntimeCounters::WorkerTotalBusyDuration => "runtime.worker_total_busy_duration",
216        }
217    }
218}
219
220/// Histogram metrics used by Relay.
221pub enum RelayDistributions {
222    /// The number of bytes received by Relay for each individual envelope item type.
223    ///
224    /// This metric is tagged with:
225    ///  - `item_type`: The type of the items being counted.
226    ///  - `is_container`: Whether this item is a container holding multiple items.
227    EnvelopeItemSize,
228    /// The size in bytes of the headers of each envelope.
229    EnvelopeHeaderSize,
230    /// The size in bytes of the header of each envelope item.
231    EnvelopeItemHeaderSize,
232    /// The amount of bytes in the item payloads of an envelope pushed to the envelope buffer.
233    ///
234    /// This is not quite the same as the actual size of a serialized envelope, because it ignores
235    /// the envelope header and item headers.
236    BufferEnvelopeBodySize,
237    /// Size of a serialized envelope pushed to the envelope buffer.
238    BufferEnvelopeSize,
239    /// Size of a compressed envelope pushed to the envelope buffer.
240    BufferEnvelopeSizeCompressed,
241    /// The number of batches emitted per partition.
242    BatchesPerPartition,
243    /// The number of buckets in a batch emitted.
244    ///
245    /// This corresponds to the number of buckets that will end up in an envelope.
246    BucketsPerBatch,
247    /// The number of spans per processed transaction event.
248    ///
249    /// This metric is tagged with:
250    ///  - `platform`: The event's platform, such as `"javascript"`.
251    ///  - `sdk`: The name of the Sentry SDK sending the transaction. This tag is only set for
252    ///    Sentry's SDKs and defaults to "proprietary".
253    EventSpans,
254    /// Number of projects in the in-memory project cache that are waiting for their state to be
255    /// updated.
256    ///
257    /// See `project_cache.size` for more description of the project cache.
258    ProjectStatePending,
259    /// Number of project states **requested** from the upstream for each batch request.
260    ///
261    /// If multiple batches are updated concurrently, this metric is reported multiple times.
262    ///
263    /// The batch size can be configured with `cache.batch_size`. See `project_cache.size` for more
264    /// description of the project cache.
265    ProjectStateRequestBatchSize,
266    /// Number of project states **returned** from the upstream for each batch request.
267    ///
268    /// If multiple batches are updated concurrently, this metric is reported multiple times.
269    ///
270    /// See `project_cache.size` for more description of the project cache.
271    ProjectStateReceived,
272    /// Number of attempts required to fetch the config for a given project key.
273    ProjectStateAttempts,
274    /// Number of project states currently held in the in-memory project cache.
275    ///
276    /// The cache duration for project states can be configured with the following options:
277    ///
278    ///  - `cache.project_expiry`: The time after which a project state counts as expired. It is
279    ///    automatically refreshed if a request references the project after it has expired.
280    ///  - `cache.project_grace_period`: The time after expiry at which the project state will still
281    ///    be used to ingest events. Once the grace period expires, the cache is evicted and new
282    ///    requests wait for an update.
283    ///
284    /// There is no limit to the number of cached projects.
285    ProjectStateCacheSize,
286    /// The size of the compressed project config in the redis cache, in bytes.
287    #[cfg(feature = "processing")]
288    ProjectStateSizeBytesCompressed,
289    /// The size of the uncompressed project config in the redis cache, in bytes.
290    #[cfg(feature = "processing")]
291    ProjectStateSizeBytesDecompressed,
292    /// The number of upstream requests queued up for sending.
293    ///
294    /// Relay employs connection keep-alive whenever possible. Connections are kept open for _15_
295    /// seconds of inactivity or _75_ seconds of activity. If all connections are busy, they are
296    /// queued, which is reflected in this metric.
297    ///
298    /// This metric is tagged with:
299    ///  - `priority`: The queueing priority of the request, either `"high"` or `"low"`. The
300    ///    priority determines precedence in executing requests.
301    ///
302    /// The number of concurrent connections can be configured with:
303    ///  - `limits.max_concurrent_requests` for the overall number of connections
304    ///  - `limits.max_concurrent_queries` for the number of concurrent high-priority requests
305    UpstreamMessageQueueSize,
306    /// Counts the number of retries for each upstream http request.
307    ///
308    /// This metric is tagged with:
309    ///  - `result`: What happened to the request, an enumeration with the following values:
310    ///    * `success`: The request was sent and returned a success code `HTTP 2xx`
311    ///    * `response_error`: The request was sent and it returned an HTTP error.
312    ///    * `payload_failed`: The request was sent but there was an error in interpreting the response.
313    ///    * `send_failed`: Failed to send the request due to a network error.
314    ///    * `rate_limited`: The request was rate limited.
315    ///    * `invalid_json`: The response could not be parsed back into JSON.
316    ///  - `upstream`: The upstream the request is sent to.
317    ///  - `route`: The endpoint that was called on the upstream.
318    ///  - `status-code`: The status code of the request when available, otherwise "-".
319    UpstreamRetries,
320    /// Size of request bodies sent over HTTP in bytes.
321    ///
322    /// This does not include requests with streaming bodies.
323    ///
324    /// This metric is tagged with:
325    ///  - `upstream`: The upstream the request is sent to.
326    ///  - `route`: The endpoint that was called on the upstream.
327    UpstreamBodySize,
328    /// Distribution of flush buckets over partition keys.
329    ///
330    /// The distribution of buckets should be even.
331    /// If it is not, this metric should expose it.
332    PartitionKeys,
333    /// Measures how many splits were performed when sending out a partition.
334    PartitionSplits,
335    /// Canonical size of a Trace Item.
336    ///
337    /// This is not the size in bytes, this is using the same algorithm we're using for the logs
338    /// billing category.
339    ///
340    /// This metric is tagged with:
341    ///  - `item`: the trace item type.
342    ///  - `too_large`: `true` or `false`, whether the item is bigger than the allowed size limit.
343    TraceItemCanonicalSize,
344    /// The Content-Length of incoming HTTP requests in bytes.
345    ///
346    /// This metric is tagged with:
347    ///  - `has_content_length`: Whether the Content-Length header was present ("true"/"false").
348    ///  - `route`: The matched route pattern.
349    ///  - `status_code`: The HTTP response status code.
350    ContentLength,
351    /// The ratio of bytes read after and before request decompression.
352    ///
353    /// Reports zero when no request body bytes were read.
354    ///
355    /// This metric is tagged with:
356    /// - `route`: The matched route pattern.
357    /// - `content_encoding`: The request's content encoding.
358    DecompressionRatio,
359}
360
361impl DistributionMetric for RelayDistributions {
362    fn name(&self) -> &'static str {
363        match self {
364            Self::EnvelopeItemSize => "event.item_size",
365            Self::EnvelopeHeaderSize => "event.envelope_header_size",
366            Self::EnvelopeItemHeaderSize => "event.item_header_size",
367            Self::EventSpans => "event.spans",
368            Self::BatchesPerPartition => "metrics.buckets.batches_per_partition",
369            Self::BucketsPerBatch => "metrics.buckets.per_batch",
370            Self::BufferEnvelopeBodySize => "buffer.envelope_body_size",
371            Self::BufferEnvelopeSize => "buffer.envelope_size",
372            Self::BufferEnvelopeSizeCompressed => "buffer.envelope_size.compressed",
373            Self::ProjectStatePending => "project_state.pending",
374            Self::ProjectStateAttempts => "project_state.attempts",
375            Self::ProjectStateRequestBatchSize => "project_state.request.batch_size",
376            Self::ProjectStateReceived => "project_state.received",
377            Self::ProjectStateCacheSize => "project_cache.size",
378            #[cfg(feature = "processing")]
379            Self::ProjectStateSizeBytesCompressed => "project_state.size_bytes.compressed",
380            #[cfg(feature = "processing")]
381            Self::ProjectStateSizeBytesDecompressed => "project_state.size_bytes.decompressed",
382            Self::UpstreamMessageQueueSize => "http_queue.size",
383            Self::UpstreamRetries => "upstream.retries",
384            Self::UpstreamBodySize => "upstream.body_size",
385            Self::PartitionKeys => "metrics.buckets.partition_keys",
386            Self::PartitionSplits => "partition_splits",
387            Self::TraceItemCanonicalSize => "trace_item.canonical_size",
388            Self::ContentLength => "requests.content_length",
389            Self::DecompressionRatio => "requests.decompression_ratio",
390        }
391    }
392}
393
394/// Timer metrics used by Relay
395pub enum RelayTimers {
396    /// Time in milliseconds spent deserializing an event from JSON bytes into the native data
397    /// structure on which Relay operates.
398    EventProcessingDeserialize,
399    /// Time in milliseconds spent running normalization on an event. Normalization
400    /// happens before envelope filtering and metric extraction.
401    EventProcessingNormalization,
402    /// Time in milliseconds spent running inbound data filters on an event.
403    EventProcessingFiltering,
404    /// Time in milliseconds spent checking for organization, project, and DSN rate limits.
405    ///
406    /// Not all events reach this point. After an event is rate limited for the first time, the rate
407    /// limit is cached. Events coming in after this will be discarded earlier in the request queue
408    /// and do not reach the processing queue.
409    ///
410    /// This metric is tagged with:
411    ///  - `type`: The type of limiter executed, `cached` or `consistent`.
412    ///  - `unit`: The item/unit of work which is being rate limited, only available for new
413    ///    processing pipelines.
414    EventProcessingRateLimiting,
415    /// Time in milliseconds spent in data scrubbing for the current event. Data scrubbing happens
416    /// last before serializing the event back to JSON.
417    EventProcessingPii,
418    /// Time spent converting the event from its in-memory reprsentation into a JSON string.
419    EventProcessingSerialization,
420    /// Time used to extract span metrics from an event.
421    EventProcessingSpanMetricsExtraction,
422    /// Time in milliseconds spent in each processor.
423    ///
424    /// This metric is tagged with:
425    ///  - `processor`: The processor executed.
426    EventProcessingProcess,
427    /// Time spent between the start of request handling and processing of the envelope.
428    ///
429    /// This includes streaming the request body, scheduling overheads, project config fetching,
430    /// batched requests and congestions in the internal processor. This does not include delays in
431    /// the incoming request (body upload) and skips all envelopes that are fast-rejected.
432    EnvelopeWaitTime,
433    /// Time in milliseconds spent in synchronous processing of envelopes.
434    ///
435    /// This timing covers the end-to-end processing in the CPU pool and comprises:
436    ///
437    ///  - `event_processing.deserialize`
438    ///  - `event_processing.pii`
439    ///  - `event_processing.serialization`
440    ///
441    /// With Relay in processing mode, this also includes the following timings:
442    ///
443    ///  - `event_processing.process`
444    ///  - `event_processing.filtering`
445    ///  - `event_processing.rate_limiting`
446    ///
447    /// This metric is tagged with:
448    /// - `is_intermediate`: Whether this envelope contains "intermediates",
449    ///   i.e. items produced by one processor for processing by others.
450    EnvelopeProcessingTime,
451    /// Total time in milliseconds an envelope spends in Relay from the time it is received until it
452    /// finishes processing and has been submitted to the upstream.
453    EnvelopeTotalTime,
454    /// Latency of project config updates until they reach Relay.
455    ///
456    /// The metric is calculated by using the creation timestamp of the project config
457    /// and when Relay updates its local cache with the new project config.
458    ///
459    /// No metric is emitted when Relay fetches a project config for the first time.
460    ///
461    /// This metric is tagged with:
462    ///  - `delay`: Bucketed amount of seconds passed between fetches.
463    ProjectCacheUpdateLatency,
464    /// Total time spent from starting to fetch a project config update to completing the fetch.
465    ProjectCacheFetchDuration,
466    /// Total time in milliseconds spent fetching queued project configuration updates requests to
467    /// resolve.
468    ///
469    /// Relay updates projects in batches. Every update cycle, Relay requests
470    /// `limits.max_concurrent_queries * cache.batch_size` projects from the upstream. This metric
471    /// measures the wall clock time for all concurrent requests in this loop.
472    ///
473    /// Note that after an update loop has completed, there may be more projects pending updates.
474    /// This is indicated by `project_state.pending`.
475    ProjectStateRequestDuration,
476    /// Time in milliseconds required to decompress a project config from redis.
477    ///
478    /// Note that this also times the cases where project config is uncompressed,
479    /// in which case the timer should be very close to zero.
480    #[cfg(feature = "processing")]
481    ProjectStateDecompression,
482    /// Total duration in milliseconds for handling inbound web requests until the HTTP response is
483    /// returned to the client.
484    ///
485    /// This does **not** correspond to the full event ingestion time. Requests for events that are
486    /// not immediately rejected due to bad data or cached rate limits always return `200 OK`. Full
487    /// validation and normalization occur asynchronously, which is reported by
488    /// `event.processing_time`.
489    ///
490    /// This metric is tagged with:
491    ///  - `method`: The HTTP method of the request.
492    ///  - `route`: Unique dashed identifier of the endpoint.
493    RequestsDuration,
494    /// Time spent on minidump scrubbing.
495    ///
496    /// This is the total time spent on parsing and scrubbing the minidump.
497    ///
498    /// This metric is tagged with:
499    ///
500    /// - `status`: Scrubbing status: "ok" means successful scrubbed, "error" means there
501    ///   was an error during scrubbing and finally "n/a" means scrubbing was successful
502    ///   but no scrubbing rules applied.
503    MinidumpScrubbing,
504    /// Time spent on view hierarchy scrubbing.
505    ///
506    /// This is the total time spent on parsing and scrubbing the view hierarchy json file.
507    ///
508    /// This metric is tagged with:
509    ///
510    /// - `status`: "ok" means successful scrubbed, "error" means there was an error during
511    ///   scrubbing. "n/a" means unchanged.
512    ViewHierarchyScrubbing,
513    /// Time spend on attachment scrubbing.
514    ///
515    /// This represents the total time spent on evaluating the scrubbing rules for an
516    /// attachment and the attachment scrubbing itself, regardless of whether any rules were
517    /// applied.  Note that minidumps which failed to be parsed (status="error" in
518    /// scrubbing.minidumps.duration) will be scrubbed as plain attachments and count
519    /// towards this.
520    ///
521    /// This metric is tagged with:
522    ///
523    ///   - `attachment_type`: The type of attachment, e.g. "minidump".
524    ///   - `status`: "ok" means successful scrubbed. "n/a" means not changed.
525    AttachmentScrubbing,
526    /// Total time spent to send request to upstream Relay and handle the response.
527    ///
528    /// This metric is tagged with:
529    ///
530    ///   - `result`: What happened to the request, an enumeration with the following values:
531    ///     * `success`: The request was sent and returned a success code `HTTP 2xx`
532    ///     * `response_error`: The request was sent and it returned an HTTP error.
533    ///     * `payload_failed`: The request was sent but there was an error in interpreting the response.
534    ///     * `send_failed`: Failed to send the request due to a network error.
535    ///     * `rate_limited`: The request was rate limited.
536    ///     * `invalid_json`: The response could not be parsed back into JSON.
537    ///   - `route`: The endpoint that was called on the upstream.
538    ///   - `status-code`: The status code of the request when available, otherwise "-".
539    ///   - `retries`: Number of retries bucket 0, 1, 2, few (3 - 10), many (more than 10).
540    UpstreamRequestsDuration,
541    /// The delay between the timestamp stated in a payload and the receive time.
542    ///
543    /// SDKs cannot transmit payloads immediately in all cases. Sometimes, crashes require that
544    /// events are sent after restarting the application. Similarly, SDKs buffer events during
545    /// network downtimes for later transmission. This metric measures the delay between the time of
546    /// the event and the time it arrives in Relay. The delay is measured after clock drift
547    /// correction is applied.
548    ///
549    /// Only payloads with a delay of more than 1 minute are captured.
550    ///
551    /// This metric is tagged with:
552    ///
553    ///  - `category`: The data category of the payload. Can be one of: `event`, `transaction`,
554    ///    `security`, or `session`.
555    TimestampDelay,
556    /// Time in milliseconds spent on parsing, normalizing and scrubbing replay recordings.
557    ReplayRecordingProcessing,
558    /// Time in milliseconds spent decompressing replay recordings to check their size.
559    ///
560    /// Processing Relays measure this for recordings which are not scrubbed. Scrubbed recordings
561    /// are checked while scrubbing, which [`Self::ReplayRecordingProcessing`] measures.
562    ReplayRecordingSizeCheck,
563    /// Total time spent to send a request and receive the response from upstream.
564    GlobalConfigRequestDuration,
565    /// Timing in milliseconds for processing a message in the internal CPU pool.
566    ///
567    /// This metric is tagged with:
568    ///
569    ///  - `message`: The type of message that was processed.
570    ProcessMessageDuration,
571    /// Timing in milliseconds for processing a task in the project cache service.
572    ///
573    /// This metric is tagged with:
574    /// - `task`: The type of the task the project cache does.
575    ProjectCacheTaskDuration,
576    /// Timing in milliseconds for awaiting a loaded project state.
577    ///
578    /// This metric is tagged with:
579    /// - `result`: Outcome of the fetch.
580    ProjectStateReadyDuration,
581    /// Timing in milliseconds for handling and responding to a health check request.
582    ///
583    /// This metric is tagged with:
584    ///  - `type`: The type of the health check, `liveness` or `readiness`.
585    HealthCheckDuration,
586    /// Temporary timing metric for how much time was spent evaluating span and transaction
587    /// rate limits using the `RateLimitBuckets` message in the processor.
588    ///
589    /// This metric is tagged with:
590    ///  - `category`: The data category evaluated.
591    ///  - `limited`: Whether the batch is rate limited.
592    ///  - `count`: How many items matching the data category are contained in the batch.
593    #[cfg(feature = "processing")]
594    RateLimitBucketsDuration,
595    /// Timing in milliseconds for processing a task in the aggregator service.
596    ///
597    /// This metric is tagged with:
598    ///  - `task`: The task being executed by the aggregator.
599    ///  - `aggregator`: The name of the aggregator.
600    AggregatorServiceDuration,
601    /// Timing in milliseconds for processing a message in the metric router service.
602    ///
603    /// This metric is tagged with:
604    ///  - `message`: The type of message that was processed.
605    MetricRouterServiceDuration,
606    /// Timing in milliseconds for processing a message in the metric store service.
607    ///
608    /// This metric is tagged with:
609    ///  - `message`: The type of message that was processed.
610    #[cfg(feature = "processing")]
611    StoreServiceDuration,
612    /// Timing in milliseconds for the time it takes for initialize the buffer.
613    BufferInitialization,
614    /// Timing in milliseconds for the time it takes for the buffer to pack & spool a batch.
615    ///
616    /// Contains the time it takes to pack multiple envelopes into a single memory blob.
617    ///
618    /// This metric is tagged with:
619    /// - `partition_id`
620    /// - `reason`: "size" or "timeout".
621    BufferSpool,
622    /// Timing in milliseconds for the time it takes for the buffer to spool data to SQLite.
623    BufferSqlWrite,
624    /// Timing in milliseconds for the time it takes for the buffer to unspool data from disk.
625    BufferUnspool,
626    /// Timing in milliseconds for the time it takes for the buffer to push.
627    BufferPush,
628    /// Timing in milliseconds for the time it takes for the buffer to peek.
629    BufferPeek,
630    /// Timing in milliseconds for the time it takes for the buffer to pop.
631    BufferPop,
632    /// Timing in milliseconds for the time it takes for the buffer to drain its envelopes.
633    BufferDrain,
634    /// Timing in milliseconds for the time it takes for an envelope to be serialized.
635    BufferEnvelopesSerialization,
636    /// Timing in milliseconds for the time it takes for an envelope to be compressed.
637    BufferEnvelopeCompression,
638    /// Timing in milliseconds for the time it takes for an envelope to be decompressed.
639    BufferEnvelopeDecompression,
640    /// Timing in milliseconds to count spans in a serialized transaction payload.
641    CheckNestedSpans,
642    /// The time it needs to create a signature. Includes both the signature used for
643    /// trusted relays and for register challenges.
644    SignatureCreationDuration,
645    /// Time needed to upload an attachment to objectstore.
646    ///
647    /// This metric measures the duration of a download attempt.
648    /// Every retry contributes to the metric individually.
649    ///
650    /// Tagged by:
651    /// - `type`: "envelope" or "attachment_v2".
652    #[cfg(feature = "processing")]
653    AttachmentUploadDuration,
654
655    /// Time spent waiting for the producer of an async stream.
656    ///
657    /// Tagged by:
658    /// - `name`: Name of the stream, for example "upload".
659    StreamProducerLatency,
660    /// Time spent waiting for the consumer of an async stream.
661    ///
662    /// Tagged by:
663    /// - `name`: Name of the stream, for example "upload".
664    StreamConsumerLatency,
665}
666
667impl TimerMetric for RelayTimers {
668    fn name(&self) -> &'static str {
669        match self {
670            RelayTimers::EventProcessingDeserialize => "event_processing.deserialize",
671            RelayTimers::EventProcessingNormalization => "event_processing.normalization",
672            RelayTimers::EventProcessingFiltering => "event_processing.filtering",
673            RelayTimers::EventProcessingRateLimiting => "event_processing.rate_limiting",
674            RelayTimers::EventProcessingPii => "event_processing.pii",
675            RelayTimers::EventProcessingSpanMetricsExtraction => {
676                "event_processing.span_metrics_extraction"
677            }
678            RelayTimers::EventProcessingSerialization => "event_processing.serialization",
679            RelayTimers::EventProcessingProcess => "event_processing.process",
680            RelayTimers::EnvelopeWaitTime => "event.wait_time",
681            RelayTimers::EnvelopeProcessingTime => "event.processing_time",
682            RelayTimers::EnvelopeTotalTime => "event.total_time",
683            RelayTimers::ProjectStateRequestDuration => "project_state.request.duration",
684            #[cfg(feature = "processing")]
685            RelayTimers::ProjectStateDecompression => "project_state.decompression",
686            RelayTimers::ProjectCacheUpdateLatency => "project_cache.latency",
687            RelayTimers::ProjectCacheFetchDuration => "project_cache.fetch.duration",
688            RelayTimers::ProjectStateReadyDuration => "project_state.ready",
689            RelayTimers::RequestsDuration => "requests.duration",
690            RelayTimers::MinidumpScrubbing => "scrubbing.minidumps.duration",
691            RelayTimers::ViewHierarchyScrubbing => "scrubbing.view_hierarchy_scrubbing.duration",
692            RelayTimers::AttachmentScrubbing => "scrubbing.attachments.duration",
693            RelayTimers::UpstreamRequestsDuration => "upstream.requests.duration",
694            RelayTimers::TimestampDelay => "requests.timestamp_delay",
695            RelayTimers::ReplayRecordingProcessing => "replay.recording.process",
696            RelayTimers::ReplayRecordingSizeCheck => "replay.recording.size_check",
697            RelayTimers::GlobalConfigRequestDuration => "global_config.requests.duration",
698            RelayTimers::ProcessMessageDuration => "processor.message.duration",
699            RelayTimers::ProjectCacheTaskDuration => "project_cache.task.duration",
700            RelayTimers::HealthCheckDuration => "health.message.duration",
701            #[cfg(feature = "processing")]
702            RelayTimers::RateLimitBucketsDuration => "processor.rate_limit_buckets",
703            RelayTimers::AggregatorServiceDuration => "metrics.aggregator.message.duration",
704            RelayTimers::MetricRouterServiceDuration => "metrics.router.message.duration",
705            #[cfg(feature = "processing")]
706            RelayTimers::StoreServiceDuration => "store.message.duration",
707            RelayTimers::BufferInitialization => "buffer.initialization.duration",
708            RelayTimers::BufferSpool => "buffer.spool.duration",
709            RelayTimers::BufferSqlWrite => "buffer.write.duration",
710            RelayTimers::BufferUnspool => "buffer.unspool.duration",
711            RelayTimers::BufferPush => "buffer.push.duration",
712            RelayTimers::BufferPeek => "buffer.peek.duration",
713            RelayTimers::BufferPop => "buffer.pop.duration",
714            RelayTimers::BufferDrain => "buffer.drain.duration",
715            RelayTimers::BufferEnvelopesSerialization => "buffer.envelopes_serialization",
716            RelayTimers::BufferEnvelopeCompression => "buffer.envelopes_compression",
717            RelayTimers::BufferEnvelopeDecompression => "buffer.envelopes_decompression",
718            RelayTimers::CheckNestedSpans => "envelope.check_nested_spans",
719            RelayTimers::SignatureCreationDuration => "signature.create.duration",
720            #[cfg(feature = "processing")]
721            RelayTimers::AttachmentUploadDuration => "attachment.upload.duration",
722            RelayTimers::StreamProducerLatency => "stream.producer.latency",
723            RelayTimers::StreamConsumerLatency => "stream.consumer.latency",
724        }
725    }
726}
727
728/// Counter metrics used by Relay
729pub enum RelayCounters {
730    /// Amount of times the configuration was reloaded.
731    ConfigReload,
732    /// Tracks the number of tasks driven to completion by the async pool.
733    ///
734    /// This metric is tagged with:
735    /// - `pool`: the name of the pool.
736    AsyncPoolFinishedTasks,
737    /// Number of Events that had corrupted (unprintable) event attributes.
738    ///
739    /// This currently checks for `environment` and `release`, for which we know that
740    /// some SDKs may send corrupted values.
741    EventCorrupted,
742    /// Number of envelopes accepted in the current time slot.
743    ///
744    /// This represents requests that have successfully passed rate limits and filters, and have
745    /// been sent to the upstream.
746    ///
747    /// This metric is tagged with:
748    ///  - `handling`: Either `"success"` if the envelope was handled correctly, or `"failure"` if
749    ///    there was an error or bug.
750    EnvelopeAccepted,
751    /// Number of envelopes rejected in the current time slot.
752    ///
753    /// This includes envelopes being rejected because they are malformed or any other errors during
754    /// processing (including filtered events, invalid payloads, and rate limits).
755    ///
756    /// To check the rejection reason, check `events.outcomes`, instead.
757    ///
758    /// This metric is tagged with:
759    ///  - `handling`: Either `"success"` if the envelope was handled correctly, or `"failure"` if
760    ///    there was an error or bug.
761    EnvelopeRejected,
762    /// Number of total envelope items we received.
763    ///
764    /// Note: This does not count raw items, it counts the logical amount of items,
765    /// e.g. a single item container counts all its contained items.
766    ///
767    /// This metric is tagged with:
768    ///  - `item_type`: The type of the items being counted.
769    ///  - `is_container`: Whether this item is a container holding multiple items.
770    ///  - `sdk`: The name of the Sentry SDK sending the envelope. This tag is only set for
771    ///    Sentry's SDKs and defaults to "proprietary".
772    EnvelopeItems,
773    /// Number of bytes we processed per envelope item.
774    ///
775    /// This metric is tagged with:
776    ///  - `item_type`: The type of the items being counted.
777    ///  - `is_container`: Whether this item is a container holding multiple items.
778    ///  - `sdk`: The name of the Sentry SDK sending the envelope. This tag is only set for
779    ///    Sentry's SDKs and defaults to "proprietary".
780    EnvelopeItemBytes,
781    /// Number of envelopes rejected because of size limits.
782    ///
783    /// This metric is tagged with:
784    ///  - `item`: The type of the items being counted.
785    ///  - `limit`: Which limit was breached.
786    EnvelopeSizeLimited,
787    /// Number of times an envelope from the buffer is trying to be popped.
788    BufferTryPop,
789    /// Number of project changed updates received by the buffer.
790    BufferProjectChangedEvent,
791    /// Number of times one or more projects of an envelope were pending when trying to pop
792    /// their envelope.
793    BufferProjectPending,
794    /// Number of iterations of the envelope buffer service loop.
795    BufferServiceLoopIteration,
796    /// Number of outcomes and reasons for rejected Envelopes.
797    ///
798    /// This metric is tagged with:
799    ///  - `outcome`: The basic cause for rejecting the event.
800    ///  - `reason`: A more detailed identifier describing the rule or mechanism leading to the
801    ///    outcome.
802    ///  - `to`: Describes the destination of the outcome. Can be either 'kafka' (when in
803    ///    processing mode) or 'http' (when outcomes are enabled in an external relay).
804    ///
805    /// Possible outcomes are:
806    ///  - `filtered`: Dropped by inbound data filters. The reason specifies the filter that
807    ///    matched.
808    ///  - `rate_limited`: Dropped by organization, project, or DSN rate limit, as well as exceeding
809    ///    the Sentry plan quota. The reason contains the rate limit or quota that was exceeded.
810    ///  - `invalid`: Data was considered invalid and could not be recovered. The reason indicates
811    ///    the validation that failed.
812    Outcomes,
813    /// The number of individual outcomes including their quantity.
814    ///
815    /// While [`RelayCounters::Outcomes`] tracks the number of times aggregated outcomes
816    /// have been emitted, this counter tracks the total quantity of individual outcomes.
817    OutcomeQuantity,
818    /// Number of project state HTTP requests.
819    ///
820    /// Relay updates projects in batches. Every update cycle, Relay requests
821    /// `limits.max_concurrent_queries` batches of `cache.batch_size` projects from the upstream.
822    /// The duration of these requests is reported via `project_state.request.duration`.
823    ///
824    /// Note that after an update loop has completed, there may be more projects pending updates.
825    /// This is indicated by `project_state.pending`.
826    ProjectStateRequest,
827    /// Number of times a project state is requested from the central Redis cache.
828    ///
829    /// This metric is tagged with:
830    ///  - `hit`: One of:
831    ///     - `revision`: the cached version was validated to be up to date using its revision.
832    ///     - `project_config`: the request was handled by the cache.
833    ///     - `project_config_revision`: the request was handled by the cache and the revision did
834    ///       not change.
835    ///     - `false`: the request will be sent to the sentry endpoint.
836    #[cfg(feature = "processing")]
837    ProjectStateRedis,
838    /// Number of times a project had a fetch scheduled.
839    ProjectCacheSchedule,
840    /// Number of times an upstream request for a project config is completed.
841    ///
842    /// Completion can be because a result was returned or because the config request was
843    /// dropped after there still was no response after a timeout.  This metrics has tags
844    /// for `result` and `attempts` indicating whether it was succesful or a timeout and how
845    /// many attempts were made respectively.
846    ProjectUpstreamCompleted,
847    /// Number of times an upstream request for a project config failed.
848    ///
849    /// Failure can happen, for example, when there's a network error. Refer to
850    /// [`UpstreamRequestError`](crate::services::upstream::UpstreamRequestError) for all cases.
851    ProjectUpstreamFailed,
852    /// Number of Relay server starts.
853    ///
854    /// This can be used to track unwanted restarts due to crashes or termination.
855    ServerStarting,
856    /// Number of messages placed on the Kafka queues.
857    ///
858    /// When Relay operates as Sentry service and an Envelope item is successfully processed, each
859    /// Envelope item results in a dedicated message on one of the ingestion topics on Kafka.
860    ///
861    /// This metric is tagged with:
862    ///  - `event_type`: The kind of message produced to Kafka.
863    ///  - `namespace` (only for metrics): The namespace that the metric belongs to.
864    ///  - `is_segment` (only for event_type span): `true` the span is the root of a segment.
865    ///  - `has_parent` (only for event_type span): `false` if the span is the root of a trace.
866    ///  - `platform` (only for event_type span): The platform from which the span was spent.
867    ///  - `metric_type` (only for event_type metric): The metric type, counter, distribution,
868    ///    gauge or set.
869    ///  - `metric_encoding` (only for event_type metric): The encoding used for distribution and
870    ///    set metrics.
871    ///
872    /// The message types can be:
873    ///
874    ///  - `event`: An error or transaction event. Error events are sent to `ingest-events`,
875    ///    transactions to `ingest-transactions`, and errors with attachments are sent to
876    ///    `ingest-attachments`.
877    ///  - `attachment`: An attachment file associated with an error event, sent to
878    ///    `ingest-attachments`.
879    ///  - `user_report`: A message from the user feedback dialog, sent to `ingest-events`.
880    ///  - `session`: A release health session update, sent to `ingest-sessions`.
881    #[cfg(feature = "processing")]
882    ProcessingMessageEnqueued,
883    /// Number of spans produced in the new format.
884    #[cfg(feature = "processing")]
885    SpanV2Produced,
886    /// Number of events that hit any of the store-like endpoints: Envelope, Store, Security,
887    /// Minidump, Unreal.
888    ///
889    /// The events are counted before they are rate limited, filtered, or processed in any way.
890    ///
891    /// This metric is tagged with:
892    ///  - `version`: The event protocol version number defaulting to `7`.
893    EventProtocol,
894    /// The number of transaction events processed by the source of the transaction name.
895    ///
896    /// This metric is tagged with:
897    ///  - `platform`: The event's platform, such as `"javascript"`.
898    ///  - `source`: The source of the transaction name on the client. See the [transaction source
899    ///    documentation](https://develop.sentry.dev/sdk/event-payloads/properties/transaction_info/)
900    ///    for all valid values.
901    ///  - `contains_slashes`: Whether the transaction name contains `/`. We use this as a heuristic
902    ///    to represent URL transactions.
903    EventTransaction,
904    /// The number of transaction events processed grouped by transaction name modifications.
905    /// This metric is tagged with:
906    ///  - `source_in`: The source of the transaction name before normalization.
907    ///    See the [transaction source
908    ///    documentation](https://develop.sentry.dev/sdk/event-payloads/properties/transaction_info/)
909    ///    for all valid values.
910    ///  - `change`: The mechanism that changed the transaction name.
911    ///    Either `"none"`, `"pattern"`, `"rule"`, or `"both"`.
912    ///  - `source_out`: The source of the transaction name after normalization.
913    TransactionNameChanges,
914    /// Number of HTTP requests reaching Relay.
915    Requests,
916    /// Number of completed HTTP requests.
917    ///
918    /// This metric is tagged with:
919    ///
920    ///  - `status_code`: The HTTP status code number.
921    ///  - `method`: The HTTP method used in the request in uppercase.
922    ///  - `route`: Unique dashed identifier of the endpoint.
923    ResponsesStatusCodes,
924    /// Number of evicted stale projects from the cache.
925    ///
926    /// Relay scans the in-memory project cache for stale entries in a regular interval configured
927    /// by `cache.eviction_interval`.
928    ///
929    /// The cache duration for project states can be configured with the following options:
930    ///
931    ///  - `cache.project_expiry`: The time after which a project state counts as expired. It is
932    ///    automatically refreshed if a request references the project after it has expired.
933    ///  - `cache.project_grace_period`: The time after expiry at which the project state will still
934    ///    be used to ingest events. Once the grace period expires, the cache is evicted and new
935    ///    requests wait for an update.
936    EvictingStaleProjectCaches,
937    /// Number of refreshes for stale projects in the cache.
938    RefreshStaleProjectCaches,
939    /// Number of times that parsing a metrics bucket item from an envelope failed.
940    MetricBucketsParsingFailed,
941    /// Number of Events with an OpenTelemetry Context
942    ///
943    /// This metric is tagged with:
944    ///  - `platform`: The event's platform, such as `"javascript"`.
945    ///  - `sdk`: The name of the Sentry SDK sending the transaction. This tag is only set for
946    ///    Sentry's SDKs and defaults to "proprietary".
947    OpenTelemetryEvent,
948    /// Number of global config fetches from upstream. Only 2XX responses are
949    /// considered and ignores send errors (e.g. auth or network errors).
950    ///
951    /// This metric is tagged with:
952    ///  - `success`: whether deserializing the global config succeeded.
953    GlobalConfigFetched,
954    /// The number of attachments processed in the same envelope as a user_report_v2 event.
955    FeedbackAttachments,
956    /// All COGS tracked values.
957    ///
958    /// This metric is tagged with:
959    /// - `resource_id`: The COGS resource id.
960    /// - `app_feature`: The COGS app feature.
961    CogsUsage,
962    /// The amount of times metrics of a project have been flushed without the project being
963    /// fetched/available.
964    ProjectStateFlushMetricsNoProject,
965    /// Incremented every time a bucket is dropped.
966    ///
967    /// This should only happen when a project state is invalid during graceful shutdown.
968    ///
969    /// This metric is tagged with:
970    ///  - `aggregator`: The name of the metrics aggregator (usually `"default"`).
971    BucketsDropped,
972    /// Incremented every time a segment exceeds the expected limit.
973    ReplayExceededSegmentLimit,
974    /// Incremented every time the server accepts a new connection.
975    ServerSocketAccept,
976    /// Incremented every time the server aborts a connection because of an idle timeout.
977    ServerConnectionIdleTimeout,
978    /// The total delay of metric buckets in seconds.
979    ///
980    /// The delay is measured from initial creation of the bucket in an internal Relay
981    /// until it is produced to Kafka.
982    ///
983    /// Use [`Self::MetricDelayCount`] to calculate the average delay.
984    ///
985    /// This metric is tagged with:
986    /// - `namespace`: the metric namespace.
987    #[cfg(feature = "processing")]
988    MetricDelaySum,
989    /// The amount of buckets counted for the [`Self::MetricDelaySum`] metric.
990    ///
991    /// This metric is tagged with:
992    /// - `namespace`: the metric namespace.
993    #[cfg(feature = "processing")]
994    MetricDelayCount,
995    /// The amount of times PlayStation processing was attempted.
996    #[cfg(all(sentry, feature = "processing"))]
997    PlaystationProcessing,
998    /// The number of times the sampling project was unresolved.
999    ///
1000    /// This metric is tagged with:
1001    /// - `item`: what item the decision is taken for (transaction vs span).
1002    SamplingProjectUnresolved,
1003    /// The number of times a sampling decision was made.
1004    ///
1005    /// This metric is tagged with:
1006    /// - `item`: what item the decision is taken for (transaction vs span).
1007    SamplingDecision,
1008    /// Number of items discarded by dynamic sampling on untrusted relays, reported via client reports.
1009    ///
1010    /// This metric is tagged with:
1011    /// - `category`: the data category of the discarded items.
1012    SamplingDroppedExternal,
1013    /// How often a call to the upload endpoint was rejected because of the global kill switch.
1014    ///
1015    /// This is intended as a temporary metric to debug 503 flakiness.
1016    UploadKillswitched,
1017    /// The number of times an upload location is created through the upload service.
1018    ///
1019    /// This metric is tagged with:
1020    /// - `result`: `success` or the failure reason.
1021    UploadCreate,
1022    /// The number of times data is uploaded to an upload location through the upload service.
1023    ///
1024    /// This metric is tagged with:
1025    /// - `result`: `success` or the failure reason.
1026    UploadUpload,
1027    /// The number of times the progress of an upload location is queried through the upload service.
1028    ///
1029    /// This metric is tagged with:
1030    /// - `result`: `success` or the failure reason.
1031    UploadHead,
1032    /// The number of times an objectstore upload of an attachment occurs.
1033    ///
1034    /// This metric is tagged with:
1035    /// - `result`: `success` or the failure reason.
1036    /// - `type`: `envelope` or `attachment_v2`
1037    #[cfg(feature = "processing")]
1038    AttachmentUpload,
1039    /// Whether a logs envelope has a trace context header or not
1040    ///
1041    /// This metric is tagged with:
1042    /// - `dsc`: yes or no
1043    /// - `sdk`: low-cardinality client name
1044    EnvelopeWithLogs,
1045    /// Amount of profile chunks without a platform item header.
1046    ///
1047    /// The metric is emitted when processing profile chunks, profile chunks which are fast path
1048    /// rate limited are not counted in this metric.
1049    ProfileChunksWithoutPlatform,
1050    /// Amount of errors have been processed by the error processing pipeline.
1051    ///
1052    /// This metric is tagged with:
1053    /// - `expansion`: What expansion was used to expand the error (e.g. unreal).
1054    ErrorProcessed,
1055    /// The number of times a trace metric has a nil trace ID.
1056    ///
1057    /// This metric is tagged with:
1058    /// - `sdk`: low-cardinality client name
1059    TraceMetricNilTraceId,
1060}
1061
1062impl CounterMetric for RelayCounters {
1063    fn name(&self) -> &'static str {
1064        match self {
1065            RelayCounters::ConfigReload => "config.reload",
1066            RelayCounters::AsyncPoolFinishedTasks => "async_pool.finished_tasks",
1067            RelayCounters::EventCorrupted => "event.corrupted",
1068            RelayCounters::EnvelopeAccepted => "event.accepted",
1069            RelayCounters::EnvelopeRejected => "event.rejected",
1070            RelayCounters::EnvelopeItems => "event.items",
1071            RelayCounters::EnvelopeItemBytes => "event.item_bytes",
1072            RelayCounters::EnvelopeSizeLimited => "envelope.rejected.size",
1073            RelayCounters::BufferTryPop => "buffer.try_pop",
1074            RelayCounters::BufferProjectChangedEvent => "buffer.project_changed_event",
1075            RelayCounters::BufferProjectPending => "buffer.project_pending",
1076            RelayCounters::BufferServiceLoopIteration => "buffer.service_loop_iteration",
1077            RelayCounters::Outcomes => "events.outcomes",
1078            RelayCounters::OutcomeQuantity => "events.outcome_quantity",
1079            RelayCounters::ProjectStateRequest => "project_state.request",
1080            #[cfg(feature = "processing")]
1081            RelayCounters::ProjectStateRedis => "project_state.redis.requests",
1082            RelayCounters::ProjectUpstreamCompleted => "project_upstream.completed",
1083            RelayCounters::ProjectUpstreamFailed => "project_upstream.failed",
1084            RelayCounters::ProjectCacheSchedule => "project_cache.schedule",
1085            RelayCounters::ServerStarting => "server.starting",
1086            #[cfg(feature = "processing")]
1087            RelayCounters::ProcessingMessageEnqueued => "processing.event.enqueued",
1088            #[cfg(feature = "processing")]
1089            RelayCounters::SpanV2Produced => "store.produced.span_v2",
1090            RelayCounters::EventProtocol => "event.protocol",
1091            RelayCounters::EventTransaction => "event.transaction",
1092            RelayCounters::TransactionNameChanges => "event.transaction_name_changes",
1093            RelayCounters::Requests => "requests",
1094            RelayCounters::ResponsesStatusCodes => "responses.status_codes",
1095            RelayCounters::EvictingStaleProjectCaches => "project_cache.eviction",
1096            RelayCounters::RefreshStaleProjectCaches => "project_cache.refresh",
1097            RelayCounters::MetricBucketsParsingFailed => "metrics.buckets.parsing_failed",
1098            RelayCounters::OpenTelemetryEvent => "event.opentelemetry",
1099            RelayCounters::GlobalConfigFetched => "global_config.fetch",
1100            RelayCounters::FeedbackAttachments => "processing.feedback_attachments",
1101            RelayCounters::CogsUsage => "cogs.usage",
1102            RelayCounters::ProjectStateFlushMetricsNoProject => "project_state.metrics.no_project",
1103            RelayCounters::BucketsDropped => "metrics.buckets.dropped",
1104            RelayCounters::ReplayExceededSegmentLimit => "replay.segment_limit_exceeded",
1105            RelayCounters::ServerSocketAccept => "server.http.accepted",
1106            RelayCounters::ServerConnectionIdleTimeout => "server.http.idle_timeout",
1107            #[cfg(feature = "processing")]
1108            RelayCounters::MetricDelaySum => "metrics.delay.sum",
1109            #[cfg(feature = "processing")]
1110            RelayCounters::MetricDelayCount => "metrics.delay.count",
1111            #[cfg(all(sentry, feature = "processing"))]
1112            RelayCounters::PlaystationProcessing => "processing.playstation",
1113            RelayCounters::SamplingProjectUnresolved => "sampling.project_unresolved",
1114            RelayCounters::SamplingDecision => "sampling.decision",
1115            RelayCounters::SamplingDroppedExternal => "sampling.dropped_external",
1116            RelayCounters::UploadKillswitched => "upload.killswitched",
1117            RelayCounters::UploadCreate => "upload.create",
1118            RelayCounters::UploadUpload => "upload.upload",
1119            RelayCounters::UploadHead => "upload.head",
1120            #[cfg(feature = "processing")]
1121            RelayCounters::AttachmentUpload => "attachment.upload",
1122            RelayCounters::EnvelopeWithLogs => "logs.envelope",
1123            RelayCounters::ProfileChunksWithoutPlatform => "profile_chunk.no_platform",
1124            RelayCounters::ErrorProcessed => "event.error.processed",
1125            RelayCounters::TraceMetricNilTraceId => "trace_metric.nil_trace_id",
1126        }
1127    }
1128}