mirror of https://github.com/fralalonde/dipstick
Clippy fixes
This commit is contained in:
parent
e3e82f86a9
commit
e7a00d9cf3
10
Cargo.toml
10
Cargo.toml
|
@ -1,11 +1,11 @@
|
|||
[package]
|
||||
name = "dipstick"
|
||||
version = "0.9.0"
|
||||
version = "0.9.1"
|
||||
authors = ["Francis Lalonde <fralalonde@gmail.com>"]
|
||||
|
||||
description = """A fast, all-purpose metrics library decoupling instrumentation from reporting backends.
|
||||
Similar to popular logging frameworks, but with counters, timers and gauges.
|
||||
Can combine outputs (e.g. log + graphite), do sampling, aggregation, periodical publication, etc."""
|
||||
description = """Fast, all-purpose metrics library decoupling instrumentation from reporting backends.
|
||||
Like logging frameworks but with counters, timers and gauges.
|
||||
Supports combined outputs (e.g. log + graphite), sampling, aggregation, scheduled push, etc."""
|
||||
|
||||
documentation = "https://docs.rs/dipstick"
|
||||
homepage = "https://github.com/fralalonde/dipstick"
|
||||
|
@ -13,7 +13,7 @@ repository = "https://github.com/fralalonde/dipstick"
|
|||
readme = "README.md"
|
||||
keywords = ["metrics", "statsd", "graphite", "timer", "prometheus"]
|
||||
license = "MIT/Apache-2.0"
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
|
||||
[badges]
|
||||
travis-ci = { repository = "fralalonde/dipstick", branch = "master" }
|
||||
|
|
|
@ -107,11 +107,9 @@ impl InnerAtomicBucket {
|
|||
.metrics
|
||||
.iter()
|
||||
.flat_map(|(name, scores)| {
|
||||
if let Some(values) = scores.reset(duration_seconds) {
|
||||
Some((name, scores.metric_kind(), values))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
scores
|
||||
.reset(duration_seconds)
|
||||
.map(|values| (name, scores.metric_kind(), values))
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
@ -429,7 +427,10 @@ impl AtomicScores {
|
|||
fn swap_if(counter: &AtomicIsize, new_value: isize, compare: fn(isize, isize) -> bool) {
|
||||
let mut current = counter.load(Acquire);
|
||||
while compare(new_value, current) {
|
||||
if counter.compare_and_swap(current, new_value, Release) == new_value {
|
||||
if counter
|
||||
.compare_exchange(current, new_value, Relaxed, Relaxed)
|
||||
.is_ok()
|
||||
{
|
||||
// update successful
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ pub type Shared<T> = Arc<RwLock<T>>;
|
|||
|
||||
pub struct Listener {
|
||||
listener_id: usize,
|
||||
listener_fn: Arc<dyn Fn(Instant) -> () + Send + Sync + 'static>,
|
||||
listener_fn: Arc<dyn Fn(Instant) + Send + Sync + 'static>,
|
||||
}
|
||||
|
||||
/// Attributes common to metric components.
|
||||
|
|
|
@ -51,7 +51,7 @@ macro_rules! labels {
|
|||
$(
|
||||
let _ = _map.insert($key.into(), ::std::sync::Arc::new($value.into()));
|
||||
)*
|
||||
crate::Labels::from(_map)
|
||||
$crate::Labels::from(_map)
|
||||
}
|
||||
};
|
||||
() => {
|
||||
|
|
|
@ -95,7 +95,7 @@ pub trait LineFormat: Send + Sync {
|
|||
#[derive(Default)]
|
||||
pub struct SimpleFormat {
|
||||
// TODO make separator configurable
|
||||
// separator: String,
|
||||
// separator: String,
|
||||
}
|
||||
|
||||
impl LineFormat for SimpleFormat {
|
||||
|
|
|
@ -10,6 +10,7 @@ use crate::name::MetricName;
|
|||
use crate::pcg32;
|
||||
use crate::{CachedInput, QueuedInput};
|
||||
use crate::{Flush, MetricValue};
|
||||
use std::fmt::Write;
|
||||
|
||||
use std::net::ToSocketAddrs;
|
||||
use std::net::UdpSocket;
|
||||
|
@ -49,9 +50,11 @@ impl Statsd {
|
|||
}
|
||||
|
||||
impl Buffered for Statsd {}
|
||||
|
||||
impl Sampled for Statsd {}
|
||||
|
||||
impl QueuedInput for Statsd {}
|
||||
|
||||
impl CachedInput for Statsd {}
|
||||
|
||||
impl Input for Statsd {
|
||||
|
@ -109,7 +112,7 @@ impl InputScope for StatsdScope {
|
|||
let metric_id = MetricId::forge("statsd", name);
|
||||
|
||||
if let Sampling::Random(float_rate) = self.get_sampling() {
|
||||
suffix.push_str(&format! {"|@{}\n", float_rate});
|
||||
let _ = write!(suffix, "|@{}\n", float_rate);
|
||||
let int_sampling_rate = pcg32::to_int_rate(float_rate);
|
||||
let metric = StatsdMetric {
|
||||
prefix,
|
||||
|
@ -123,7 +126,7 @@ impl InputScope for StatsdScope {
|
|||
}
|
||||
})
|
||||
} else {
|
||||
suffix.push_str("\n");
|
||||
suffix.push('\n');
|
||||
let metric = StatsdMetric {
|
||||
prefix,
|
||||
suffix,
|
||||
|
@ -262,7 +265,6 @@ impl Drop for StatsdScope {
|
|||
|
||||
#[cfg(feature = "bench")]
|
||||
mod bench {
|
||||
|
||||
use super::*;
|
||||
use crate::attributes::*;
|
||||
use crate::input::*;
|
||||
|
|
|
@ -39,7 +39,7 @@ fn pcg32_random() -> u32 {
|
|||
/// all | 1.0 | 0x0 | 100%
|
||||
/// none | 0.0 | 0xFFFFFFFF | 0%
|
||||
pub fn to_int_rate(float_rate: f64) -> u32 {
|
||||
assert!(float_rate <= 1.0 && float_rate >= 0.0);
|
||||
assert!((0.0..=1.0).contains(&float_rate));
|
||||
((1.0 - float_rate) * f64::from(::std::u32::MAX)) as u32
|
||||
}
|
||||
|
||||
|
|
|
@ -236,7 +236,7 @@ impl InputScope for Proxy {
|
|||
.metrics
|
||||
.get(&name)
|
||||
// TODO validate that InputKind matches existing
|
||||
.and_then(|proxy_ref| Weak::upgrade(proxy_ref))
|
||||
.and_then(Weak::upgrade)
|
||||
.unwrap_or_else(|| {
|
||||
let namespace = &*name;
|
||||
{
|
||||
|
|
|
@ -102,7 +102,7 @@ struct ScheduledTask {
|
|||
next_time: Instant,
|
||||
period: Duration,
|
||||
handle: CancelHandle,
|
||||
operation: Arc<dyn Fn(Instant) -> () + Send + Sync + 'static>,
|
||||
operation: Arc<dyn Fn(Instant) + Send + Sync + 'static>,
|
||||
}
|
||||
|
||||
impl Ord for ScheduledTask {
|
||||
|
@ -185,7 +185,7 @@ impl Scheduler {
|
|||
/// Schedule a task to run periodically.
|
||||
pub fn schedule<F>(&self, period: Duration, operation: F) -> CancelHandle
|
||||
where
|
||||
F: Fn(Instant) -> () + Send + Sync + 'static,
|
||||
F: Fn(Instant) + Send + Sync + 'static,
|
||||
{
|
||||
let handle = CancelHandle::new();
|
||||
let new_task = ScheduledTask {
|
||||
|
|
Loading…
Reference in New Issue