relay_system/statsd.rs
1use relay_statsd::{CounterMetric, GaugeMetric};
2
3/// Counter metrics for Relay system components.
4pub enum SystemCounters {
5 /// Number of runtime tasks created/spawned.
6 ///
7 /// Every call to [`spawn`](`crate::spawn()`) increases this counter by one.
8 ///
9 /// This metric is tagged with:
10 /// - `id`: A unique identifier for the task, derived from its location in code.
11 /// - `file`: The source filename where the task is created.
12 /// - `line`: The source line where the task is created within the file.
13 RuntimeTaskCreated,
14 /// Number of runtime tasks terminated.
15 ///
16 /// This metric is tagged with:
17 /// - `id`: A unique identifier for the task, derived from its location in code.
18 /// - `file`: The source filename where the task is created.
19 /// - `line`: The source line where the task is created within the file.
20 RuntimeTaskTerminated,
21}
22
23impl CounterMetric for SystemCounters {
24 fn name(&self) -> &'static str {
25 match self {
26 Self::RuntimeTaskCreated => "runtime.task.spawn.created",
27 Self::RuntimeTaskTerminated => "runtime.task.spawn.terminated",
28 }
29 }
30}
31
32/// Gauge metrics for Relay system components.
33pub enum SystemGauges {
34 /// A number of messages queued in a services inbound message channel.
35 ///
36 /// This metric is emitted once per second for every running service. Without backlogs, this
37 /// number should be close to `0`. If this number is monotonically increasing, the service is
38 /// not able to process the inbound message volume.
39 ///
40 /// This metric is tagged with:
41 /// - `service`: The fully qualified type name of the service implementation.
42 ServiceBackPressure,
43}
44
45impl GaugeMetric for SystemGauges {
46 fn name(&self) -> &'static str {
47 match *self {
48 Self::ServiceBackPressure => "service.back_pressure",
49 }
50 }
51}