pub struct PrometheusExporter { /* private fields */ }Expand description
Exports metrics by exposing a Prometheus exporter endpoint.
Implementations§
Source§impl PrometheusExporter
impl PrometheusExporter
Sourcepub fn new(controller: Controller, addr: SocketAddr) -> Self
pub fn new(controller: Controller, addr: SocketAddr) -> Self
Creates a new PrometheusExporter.
When run/spawned, the exporter will listen at the given socket address, responding to any requests by taking a snapshot and returning it in the text-based Prometheus exposition format.
Sourcepub fn run(self)
pub fn run(self)
Runs the exporter synchronously, blocking the calling thread.
You should run this in a dedicated thread:
let addr = "localhost:9090".parse().expect("failed to parse listen address");
let mut exporter = PrometheusExporter::new(controller, addr);
std::thread::spawn(move || exporter.run());Sourcepub fn into_future(self) -> impl Future<Item = (), Error = HyperError> + Send
pub fn into_future(self) -> impl Future<Item = (), Error = HyperError> + Send
Converts this exporter into a future that runs the Hyper-based exporter endpoint.
let addr = "localhost:9090".parse().expect("failed to parse listen address");
let exporter = PrometheusExporter::new(controller, addr);
let server = exporter.into_future().map_err(|_| ());
tokio::run(server);Auto Trait Implementations§
impl Freeze for PrometheusExporter
impl RefUnwindSafe for PrometheusExporter
impl Send for PrometheusExporter
impl Sync for PrometheusExporter
impl Unpin for PrometheusExporter
impl UnwindSafe for PrometheusExporter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more