Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
jstuczyn committed Dec 19, 2024
1 parent b7c7b6e commit 7efa470
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 22 deletions.
4 changes: 4 additions & 0 deletions common/nonexhaustive-delayqueue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ impl<T> NonExhaustiveDelayQueue<T> {
pub fn len(&self) -> usize {
self.inner.len()
}

pub fn is_empty(&self) -> bool {
self.inner.is_empty()
}
}

impl<T> Default for NonExhaustiveDelayQueue<T> {
Expand Down
12 changes: 6 additions & 6 deletions common/nym-metrics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ impl MetricsController {
self.register_metric(metric);
}

pub fn set<'a>(&self, name: &str, value: i64) -> bool {
pub fn set(&self, name: &str, value: i64) -> bool {
if let Some(metric) = self.registry_index.get(name) {
metric.set(value);
true
Expand All @@ -413,7 +413,7 @@ impl MetricsController {
}
}

pub fn set_float<'a>(&self, name: &str, value: f64) -> bool {
pub fn set_float(&self, name: &str, value: f64) -> bool {
if let Some(metric) = self.registry_index.get(name) {
metric.set_float(value);
true
Expand All @@ -422,7 +422,7 @@ impl MetricsController {
}
}

pub fn add_to_histogram<'a>(&self, name: &str, value: f64) -> bool {
pub fn add_to_histogram(&self, name: &str, value: f64) -> bool {
if let Some(metric) = self.registry_index.get(name) {
metric.add_histogram_observation(value);
true
Expand All @@ -431,13 +431,13 @@ impl MetricsController {
}
}

pub fn start_timer<'a>(&self, name: &str) -> Option<HistogramTimer> {
pub fn start_timer(&self, name: &str) -> Option<HistogramTimer> {
self.registry_index
.get(name)
.and_then(|metric| metric.start_timer())
}

pub fn inc<'a>(&self, name: &str) -> bool {
pub fn inc(&self, name: &str) -> bool {
if let Some(metric) = self.registry_index.get(name) {
metric.inc();
true
Expand All @@ -446,7 +446,7 @@ impl MetricsController {
}
}

pub fn inc_by<'a>(&self, name: &str, value: i64) -> bool {
pub fn inc_by(&self, name: &str, value: i64) -> bool {
if let Some(metric) = self.registry_index.get(name) {
metric.inc_by(value);
true
Expand Down
7 changes: 0 additions & 7 deletions nym-node/nym-node-metrics/src/mixnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,6 @@ impl MixingStats {
.or_default()
.dropped += 1;
}

pub fn egress_dropped_final_hop_packet(&self) {
todo!()
// self.egress
// .final_hop_packets_dropped
// .fetch_add(1, Ordering::Relaxed);
}
}

#[derive(Clone, Copy, Default, PartialEq)]
Expand Down
13 changes: 7 additions & 6 deletions nym-node/nym-node-metrics/src/prometheus_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::sync::LazyLock;
use strum::{Display, EnumCount, EnumIter, EnumProperty, IntoEnumIterator};

pub static PROMETHEUS_METRICS: LazyLock<NymNodePrometheusMetrics> =
LazyLock::new(|| NymNodePrometheusMetrics::initialise());
LazyLock::new(NymNodePrometheusMetrics::initialise);

const CLIENT_SESSION_DURATION_BUCKETS: &[f64] = &[
// sub 3s (implicitly)
Expand Down Expand Up @@ -178,10 +178,11 @@ impl PrometheusMetric {
}

fn is_complex(&self) -> bool {
match self {
PrometheusMetric::EntryClientSessionsDurations { .. } => true,
_ => false,
}
matches!(self, PrometheusMetric::EntryClientSessionsDurations { .. })
// match self {
// PrometheusMetric::EntryClientSessionsDurations { .. } => true,
// _ => false,
// }
}

fn to_registrable_metric(&self) -> Option<Metric> {
Expand Down Expand Up @@ -244,7 +245,7 @@ impl PrometheusMetric {
PrometheusMetric::EntryClientSessionsStarted => Metric::new_int_gauge(&name, help),
PrometheusMetric::EntryClientSessionsFinished => Metric::new_int_gauge(&name, help),
PrometheusMetric::EntryClientSessionsDurations { .. } => {
Metric::new_histogram(&name, help, Some(&CLIENT_SESSION_DURATION_BUCKETS))
Metric::new_histogram(&name, help, Some(CLIENT_SESSION_DURATION_BUCKETS))
}
PrometheusMetric::WireguardBytesTx => Metric::new_int_gauge(&name, help),
PrometheusMetric::WireguardBytesRx => Metric::new_int_gauge(&name, help),
Expand Down
4 changes: 1 addition & 3 deletions nym-node/src/node/http/router/api/v1/metrics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ where
.route(metrics::SESSIONS, get(sessions_stats))
.route(metrics::VERLOC, get(verloc_stats));

let auth_middleware = config
.bearer_token
.map(|bearer_token| AuthLayer::new(bearer_token));
let auth_middleware = config.bearer_token.map(AuthLayer::new);

// don't expose prometheus route without bearer token set
if let Some(auth_middleware) = auth_middleware {
Expand Down

0 comments on commit 7efa470

Please sign in to comment.