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