|
1 | 1 | //! Metrics support for the server
|
2 | 2 |
|
3 |
| -use iroh_metrics::core::{Core, Counter, Metric}; |
4 |
| -use struct_iterable::Iterable; |
| 3 | +use iroh_metrics::{Counter, MetricsGroup}; |
5 | 4 |
|
6 | 5 | /// Metrics for iroh-dns-server
|
7 |
| -#[derive(Debug, Clone, Iterable)] |
8 |
| -#[allow(missing_docs)] |
| 6 | +#[derive(Debug, Default, MetricsGroup)] |
| 7 | +#[metrics(name = "dns_server")] |
9 | 8 | pub struct Metrics {
|
| 9 | + /// Number of pkarr relay puts that updated the state |
10 | 10 | pub pkarr_publish_update: Counter,
|
| 11 | + /// Number of pkarr relay puts that did not update the state |
11 | 12 | pub pkarr_publish_noop: Counter,
|
| 13 | + /// DNS requests (total) |
12 | 14 | pub dns_requests: Counter,
|
| 15 | + /// DNS requests via UDP |
13 | 16 | pub dns_requests_udp: Counter,
|
| 17 | + /// DNS requests via HTTPS (DoH) |
14 | 18 | pub dns_requests_https: Counter,
|
| 19 | + /// DNS lookup responses with at least one answer |
15 | 20 | pub dns_lookup_success: Counter,
|
| 21 | + /// DNS lookup responses with no answers |
16 | 22 | pub dns_lookup_notfound: Counter,
|
| 23 | + /// DNS lookup responses which failed |
17 | 24 | pub dns_lookup_error: Counter,
|
| 25 | + /// Number of HTTP requests |
18 | 26 | pub http_requests: Counter,
|
| 27 | + /// Number of HTTP requests with a 2xx status code |
19 | 28 | pub http_requests_success: Counter,
|
| 29 | + /// Number of HTTP requests with a non-2xx status code |
20 | 30 | pub http_requests_error: Counter,
|
| 31 | + /// Total duration of all HTTP requests |
21 | 32 | pub http_requests_duration_ms: Counter,
|
| 33 | + /// Signed packets inserted into the store |
22 | 34 | pub store_packets_inserted: Counter,
|
| 35 | + /// Signed packets removed from the store |
23 | 36 | pub store_packets_removed: Counter,
|
| 37 | + /// Number of updates to existing packets |
24 | 38 | pub store_packets_updated: Counter,
|
| 39 | + /// Number of expired packets |
25 | 40 | pub store_packets_expired: Counter,
|
26 | 41 | }
|
27 |
| - |
28 |
| -impl Default for Metrics { |
29 |
| - fn default() -> Self { |
30 |
| - Self { |
31 |
| - pkarr_publish_update: Counter::new("Number of pkarr relay puts that updated the state"), |
32 |
| - pkarr_publish_noop: Counter::new( |
33 |
| - "Number of pkarr relay puts that did not update the state", |
34 |
| - ), |
35 |
| - dns_requests: Counter::new("DNS requests (total)"), |
36 |
| - dns_requests_udp: Counter::new("DNS requests via UDP"), |
37 |
| - dns_requests_https: Counter::new("DNS requests via HTTPS (DoH)"), |
38 |
| - dns_lookup_success: Counter::new("DNS lookup responses with at least one answer"), |
39 |
| - dns_lookup_notfound: Counter::new("DNS lookup responses with no answers"), |
40 |
| - dns_lookup_error: Counter::new("DNS lookup responses which failed"), |
41 |
| - http_requests: Counter::new("Number of HTTP requests"), |
42 |
| - http_requests_success: Counter::new("Number of HTTP requests with a 2xx status code"), |
43 |
| - http_requests_error: Counter::new("Number of HTTP requests with a non-2xx status code"), |
44 |
| - http_requests_duration_ms: Counter::new("Total duration of all HTTP requests"), |
45 |
| - store_packets_inserted: Counter::new("Signed packets inserted into the store"), |
46 |
| - store_packets_removed: Counter::new("Signed packets removed from the store"), |
47 |
| - store_packets_updated: Counter::new("Number of updates to existing packets"), |
48 |
| - store_packets_expired: Counter::new("Number of expired packets"), |
49 |
| - } |
50 |
| - } |
51 |
| -} |
52 |
| - |
53 |
| -impl Metric for Metrics { |
54 |
| - fn name() -> &'static str { |
55 |
| - "dns_server" |
56 |
| - } |
57 |
| -} |
58 |
| - |
59 |
| -/// Init the metrics collection core. |
60 |
| -pub fn init_metrics() { |
61 |
| - Core::init(|reg, metrics| { |
62 |
| - metrics.insert(Metrics::new(reg)); |
63 |
| - }); |
64 |
| -} |
0 commit comments