Bump dependencies of metrics-runtime (#74)
This commit is contained in:
parent
0d98ceffb3
commit
c766fc0d47
|
@ -6,7 +6,7 @@ jobs:
|
|||
Linux:
|
||||
vmImage: ubuntu-16.04
|
||||
MacOS:
|
||||
vmImage: macOS-10.13
|
||||
vmImage: macOS-10.14
|
||||
Windows:
|
||||
vmImage: vs2017-win2016
|
||||
pool:
|
||||
|
|
|
@ -6,7 +6,7 @@ jobs:
|
|||
Linux:
|
||||
vmImage: ubuntu-16.04
|
||||
MacOS:
|
||||
vmImage: macOS-10.13
|
||||
vmImage: macOS-10.14
|
||||
Windows:
|
||||
vmImage: vs2017-win2016
|
||||
pool:
|
||||
|
|
|
@ -6,7 +6,7 @@ jobs:
|
|||
Linux:
|
||||
vmImage: ubuntu-16.04
|
||||
MacOS:
|
||||
vmImage: macOS-10.13
|
||||
vmImage: macOS-10.14
|
||||
Windows:
|
||||
vmImage: vs2017-win2016
|
||||
pool:
|
||||
|
|
|
@ -28,11 +28,11 @@ harness = false
|
|||
metrics-core = { path = "../metrics-core", version = "^0.5" }
|
||||
metrics-util = { path = "../metrics-util", version = "^0.3" }
|
||||
metrics = { path = "../metrics", version = "^0.12", features = ["std"] }
|
||||
im = "^12"
|
||||
arc-swap = "^0.3"
|
||||
parking_lot = "^0.9"
|
||||
im = "^15"
|
||||
arc-swap = "^0.4"
|
||||
parking_lot = "^0.10"
|
||||
quanta = "^0.3"
|
||||
crossbeam-utils = "^0.6"
|
||||
crossbeam-utils = "^0.7"
|
||||
metrics-exporter-log = { path = "../metrics-exporter-log", version = "^0.4", optional = true }
|
||||
metrics-exporter-http = { path = "../metrics-exporter-http", version = "^0.3", optional = true }
|
||||
metrics-observer-yaml = { path = "../metrics-observer-yaml", version = "^0.1", optional = true }
|
||||
|
@ -41,9 +41,9 @@ metrics-observer-json = { path = "../metrics-observer-json", version = "^0.1", o
|
|||
|
||||
[dev-dependencies]
|
||||
log = "^0.4"
|
||||
env_logger = "^0.6"
|
||||
env_logger = "^0.7"
|
||||
getopts = "^0.2"
|
||||
hdrhistogram = "^6.1"
|
||||
criterion = "^0.2.9"
|
||||
hdrhistogram = "^7.1"
|
||||
criterion = "^0.3"
|
||||
lazy_static = "^1.3"
|
||||
tokio = { version = "^0.2", features = ["macros", "rt-core"] }
|
||||
|
|
|
@ -12,10 +12,9 @@ use std::time::Duration;
|
|||
lazy_static! {
|
||||
static ref QUANTA_UPKEEP: UpkeepHandle = {
|
||||
let builder = UpkeepBuilder::new(Duration::from_millis(10));
|
||||
let handle = builder
|
||||
builder
|
||||
.start()
|
||||
.expect("failed to start quanta upkeep thread");
|
||||
handle
|
||||
.expect("failed to start quanta upkeep thread")
|
||||
};
|
||||
static ref RANDOM_INTS: Vec<u64> = vec![
|
||||
21061184, 21301862, 21331592, 21457012, 21500016, 21537837, 21581557, 21620030, 21664102,
|
||||
|
@ -69,7 +68,7 @@ fn bucket_benchmark(c: &mut Criterion) {
|
|||
}
|
||||
})
|
||||
})
|
||||
.throughput(Throughput::Elements(RANDOM_INTS.len() as u32)),
|
||||
.throughput(Throughput::Elements(RANDOM_INTS.len() as u64)),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -212,9 +212,9 @@ impl ValueHandle {
|
|||
ValueSnapshot::Single(Measurement::Histogram(stream))
|
||||
}
|
||||
ValueState::Proxy(maybe) => {
|
||||
let measurements = match maybe.load() {
|
||||
let measurements = match *maybe.load() {
|
||||
None => Vec::new(),
|
||||
Some(f) => f(),
|
||||
Some(ref f) => f(),
|
||||
};
|
||||
|
||||
ValueSnapshot::Multiple(measurements)
|
||||
|
|
|
@ -2,11 +2,10 @@ use crate::common::{Identifier, Kind, Measurement, ValueHandle, ValueSnapshot};
|
|||
use crate::config::Configuration;
|
||||
use crate::data::Snapshot;
|
||||
use crate::registry::ScopeRegistry;
|
||||
use arc_swap::{ptr_eq, ArcSwap};
|
||||
use arc_swap::ArcSwap;
|
||||
use im::hashmap::HashMap;
|
||||
use metrics_core::Observer;
|
||||
use quanta::Clock;
|
||||
use std::ops::Deref;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -29,7 +28,8 @@ impl MetricRegistry {
|
|||
|
||||
pub fn get_or_register(&self, id: Identifier) -> ValueHandle {
|
||||
loop {
|
||||
match self.metrics.lease().deref().get(&id) {
|
||||
let old_metrics = self.metrics.load();
|
||||
match old_metrics.get(&id) {
|
||||
Some(handle) => return handle.clone(),
|
||||
None => {
|
||||
let value_handle = match id.kind() {
|
||||
|
@ -43,23 +43,22 @@ impl MetricRegistry {
|
|||
Kind::Proxy => ValueHandle::proxy(),
|
||||
};
|
||||
|
||||
let metrics_ptr = self.metrics.lease();
|
||||
let mut metrics = metrics_ptr.deref().clone();
|
||||
match metrics.insert(id.clone(), value_handle.clone()) {
|
||||
// Somebody else beat us to it, loop.
|
||||
Some(_) => continue,
|
||||
let mut new_metrics = (**self.metrics.load()).clone();
|
||||
match new_metrics.insert(id.clone(), value_handle.clone()) {
|
||||
Some(other_value_handle) => {
|
||||
// Somebody else beat us to it.
|
||||
return other_value_handle;
|
||||
}
|
||||
None => {
|
||||
// If we weren't able to cleanly update the map, then try again.
|
||||
let old = self
|
||||
let prev_metrics = self
|
||||
.metrics
|
||||
.compare_and_swap(&metrics_ptr, Arc::new(metrics));
|
||||
if !ptr_eq(old, metrics_ptr) {
|
||||
continue;
|
||||
.compare_and_swap(&old_metrics, Arc::new(new_metrics));
|
||||
if Arc::ptr_eq(&old_metrics, &prev_metrics) {
|
||||
return value_handle;
|
||||
}
|
||||
// If we weren't able to cleanly update the map, then try again.
|
||||
}
|
||||
}
|
||||
|
||||
return value_handle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +67,7 @@ impl MetricRegistry {
|
|||
pub fn snapshot(&self) -> Snapshot {
|
||||
let mut values = Vec::new();
|
||||
|
||||
let metrics = self.metrics.load().deref().clone();
|
||||
let metrics = (**self.metrics.load()).clone();
|
||||
for (id, value) in metrics.into_iter() {
|
||||
let (key, scope_handle, _) = id.into_parts();
|
||||
let scope = self.scope_registry.get(scope_handle);
|
||||
|
@ -98,7 +97,7 @@ impl MetricRegistry {
|
|||
}
|
||||
|
||||
pub fn observe<O: Observer>(&self, observer: &mut O) {
|
||||
let metrics = self.metrics.load().deref().clone();
|
||||
let metrics = (**self.metrics.load()).clone();
|
||||
for (id, value) in metrics.into_iter() {
|
||||
let (key, scope_handle, _) = id.into_parts();
|
||||
let scope = self.scope_registry.get(scope_handle);
|
||||
|
@ -236,7 +235,7 @@ mod tests {
|
|||
Measurement::Histogram(StreamingIntegers::new()),
|
||||
),
|
||||
(
|
||||
Key::from_name_and_labels("proxy.counter", labels.clone()),
|
||||
Key::from_name_and_labels("proxy.counter", labels),
|
||||
Measurement::Counter(13),
|
||||
),
|
||||
];
|
||||
|
|
|
@ -721,7 +721,7 @@ mod tests {
|
|||
.join(",");
|
||||
assert_eq!(label_str, "type=test");
|
||||
|
||||
sink.add_default_labels(&[(("service", "foo"))]);
|
||||
sink.add_default_labels(&[("service", "foo")]);
|
||||
|
||||
let no_labels = sink.construct_key("bar");
|
||||
assert_eq!(no_labels.name(), "bar");
|
||||
|
|
Loading…
Reference in New Issue