Update exporters/recorders to use new metrics-util.
This commit is contained in:
parent
29eb316438
commit
ebe5d9266b
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "metrics-exporter-http"
|
name = "metrics-exporter-http"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
authors = ["Toby Lawrence <toby@nuclearfurnace.com>"]
|
authors = ["Toby Lawrence <toby@nuclearfurnace.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
|
|
@ -11,13 +11,13 @@
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate log;
|
extern crate log;
|
||||||
|
|
||||||
|
use hyper::rt::run as hyper_run;
|
||||||
|
use hyper::rt::Future;
|
||||||
|
use hyper::service::service_fn;
|
||||||
|
use hyper::{Body, Response, Server};
|
||||||
use metrics_core::{AsyncSnapshotProvider, Recorder, Snapshot};
|
use metrics_core::{AsyncSnapshotProvider, Recorder, Snapshot};
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use hyper::{Body, Response, Server};
|
|
||||||
use hyper::service::service_fn;
|
|
||||||
use hyper::rt::run as hyper_run;
|
|
||||||
use hyper::rt::Future;
|
|
||||||
|
|
||||||
/// Exports metrics over HTTP.
|
/// Exports metrics over HTTP.
|
||||||
pub struct HttpExporter<C, R> {
|
pub struct HttpExporter<C, R> {
|
||||||
|
@ -54,7 +54,6 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts this exporter into a future which can be driven externally.
|
/// Converts this exporter into a future which can be driven externally.
|
||||||
/// logs output on the given interval.
|
|
||||||
///
|
///
|
||||||
/// This starts an HTTP server on the `address` the exporter was originally configured with,
|
/// This starts an HTTP server on the `address` the exporter was originally configured with,
|
||||||
/// responding to any request with the output of the configured recorder.
|
/// responding to any request with the output of the configured recorder.
|
||||||
|
@ -67,7 +66,11 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_hyper_server<C, R>(controller: C, recorder: R, address: SocketAddr) -> impl Future<Item = (), Error = ()>
|
fn build_hyper_server<C, R>(
|
||||||
|
controller: C,
|
||||||
|
recorder: R,
|
||||||
|
address: SocketAddr,
|
||||||
|
) -> impl Future<Item = (), Error = ()>
|
||||||
where
|
where
|
||||||
C: AsyncSnapshotProvider + Clone + Send + 'static,
|
C: AsyncSnapshotProvider + Clone + Send + 'static,
|
||||||
C::SnapshotFuture: Send + 'static,
|
C::SnapshotFuture: Send + 'static,
|
||||||
|
@ -81,14 +84,15 @@ where
|
||||||
service_fn(move |_| {
|
service_fn(move |_| {
|
||||||
let recorder3 = recorder2.clone();
|
let recorder3 = recorder2.clone();
|
||||||
|
|
||||||
controller2.get_snapshot_async()
|
controller2
|
||||||
|
.get_snapshot_async()
|
||||||
.then(move |result| match result {
|
.then(move |result| match result {
|
||||||
Ok(snapshot) => {
|
Ok(snapshot) => {
|
||||||
let mut r = recorder3.clone();
|
let mut r = recorder3.clone();
|
||||||
snapshot.record(&mut r);
|
snapshot.record(&mut r);
|
||||||
let output = r.into();
|
let output = r.into();
|
||||||
Ok(Response::new(Body::from(output)))
|
Ok(Response::new(Body::from(output)))
|
||||||
},
|
}
|
||||||
Err(e) => Err(e),
|
Err(e) => Err(e),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "metrics-recorder-prometheus"
|
name = "metrics-recorder-prometheus"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
authors = ["Toby Lawrence <toby@nuclearfurnace.com>"]
|
authors = ["Toby Lawrence <toby@nuclearfurnace.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
@ -14,5 +14,5 @@ documentation = "https://docs.rs/metrics-recorder-prometheus"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
metrics-core = { path = "../metrics-core", version = "^0.3" }
|
metrics-core = { path = "../metrics-core", version = "^0.3" }
|
||||||
metrics-util = { path = "../metrics-util", version = "^0.1" }
|
metrics-util = { path = "../metrics-util", version = "^0.2" }
|
||||||
hdrhistogram = "^6.1"
|
hdrhistogram = "^6.1"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "metrics-recorder-text"
|
name = "metrics-recorder-text"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
authors = ["Toby Lawrence <toby@nuclearfurnace.com>"]
|
authors = ["Toby Lawrence <toby@nuclearfurnace.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
@ -14,5 +14,5 @@ documentation = "https://docs.rs/metrics-recorder-text"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
metrics-core = { path = "../metrics-core", version = "^0.3" }
|
metrics-core = { path = "../metrics-core", version = "^0.3" }
|
||||||
metrics-util = { path = "../metrics-util", version = "^0.1" }
|
metrics-util = { path = "../metrics-util", version = "^0.2" }
|
||||||
hdrhistogram = "^6.1"
|
hdrhistogram = "^6.1"
|
||||||
|
|
Loading…
Reference in New Issue