Remove more lint, bump ton num 0.2

This commit is contained in:
Francis Lalonde 2018-10-04 17:28:25 -04:00
parent 79cc69fd0b
commit 7ac4908cba
8 changed files with 13 additions and 10 deletions

View File

@ -22,7 +22,7 @@ log = "0.4"
lazy_static = "1"
atomic_refcell = "0.1"
skeptic = { version = "0.13", optional = true }
num = { version = "0.1", default-features = false }
num = { version = "0.2", default-features = false }
# FIXME required only for random seed for sampling
time = "0.1"

View File

@ -11,11 +11,11 @@ use std::env::args;
use std::str::FromStr;
fn main() {
let event = Proxy::default_root().marker("a");
let event = Proxy::default().marker("a");
let bucket = Bucket::new();
Proxy::default_root().set_target(bucket.clone());
Proxy::default().set_target(bucket.clone());
let args = &mut args();
args.next();

View File

@ -36,7 +36,7 @@ fn main() {
.namespace("machine_name");
// send application metrics to aggregator
Proxy::default_root().set_target(all_buckets);
Proxy::default().set_target(all_buckets);
Bucket::set_default_target(Text::write_to(io::stdout()));
Bucket::set_default_stats(stats_all);

View File

@ -9,7 +9,7 @@ use dipstick::{Proxy, Text, InputScope, Input, Naming};
fn main() {
let root = Proxy::default_root();
let root = Proxy::default();
let sub = root.namespace("sub");
let count1 = root.counter("counter_a");

View File

@ -123,7 +123,7 @@ impl InnerBucket {
}
}
}
Ok(publish_scope.flush()?)
publish_scope.flush()
}
}

View File

@ -35,12 +35,14 @@ impl Namespace {
true
}
/// Make a name in this namespace
pub fn qualify<S: Into<String>>(&self, leaf: S) -> Name {
let mut nodes = self.clone();
nodes.push_back(leaf.into());
Name { nodes }
}
/// Create a new Name using only the last part (leaf)
pub fn leaf(&self) -> Name {
self.back().expect("Short metric name").clone().into()
}

View File

@ -54,13 +54,14 @@ pub struct Proxy {
inner: Arc<RwLock<InnerProxy>>,
}
impl Proxy {
impl Default for Proxy {
/// Return the default root metric proxy.
pub fn default_root() -> Proxy {
fn default() -> Self {
ROOT_PROXY.clone()
}
}
struct InnerProxy {
// namespaces can target one, many or no metrics
targets: HashMap<Namespace, Arc<InputScope + Send + Sync>>,

View File

@ -54,13 +54,13 @@ macro_rules! metrics {
// LEAF NODE - public typed decl
($(#[$attr:meta])* pub $IDENT:ident: $TYPE:ty = $e:expr; $($REST:tt)*) => {
__in_context!{ Proxy::default_root(); Proxy; $(#[$attr])* pub $IDENT: $TYPE = $e; }
__in_context!{ Proxy::default(); Proxy; $(#[$attr])* pub $IDENT: $TYPE = $e; }
metrics!{ $($REST)* }
};
// LEAF NODE - private typed decl
($(#[$attr:meta])* $IDENT:ident: $TYPE:ty = $e:expr; $($REST:tt)*) => {
__in_context!{ Proxy::default_root(); Proxy; $(#[$attr])* $IDENT: $TYPE = $e; }
__in_context!{ Proxy::default(); Proxy; $(#[$attr])* $IDENT: $TYPE = $e; }
metrics!{ $($REST)* }
};