pub struct PrometheusClientLayer { /* private fields */ }Expand description
Add prometheus-client for every operation.
§Prometheus Metrics
We provide several metrics, please see the documentation of observe module.
For a more detailed explanation of these metrics and how they are used, please refer to the Prometheus documentation.
§Examples
let mut registry = prometheus_client::registry::Registry::default();
let op = Operator::new(services::Memory::default())?
.layer(PrometheusClientLayer::builder().register(&mut registry))
.finish();
// Write data into object test.
op.write("test", "Hello, World!").await?;
// Read data from the object.
let bs = op.read("test").await?;
info!("content: {}", String::from_utf8_lossy(&bs.to_bytes()));
// Get object metadata.
let meta = op.stat("test").await?;
info!("meta: {:?}", meta);
// Export prometheus metrics.
let mut buf = String::new();
prometheus_client::encoding::text::encode(&mut buf, ®istry).unwrap();
println!("## Prometheus Metrics");
println!("{}", buf);Implementations§
Source§impl PrometheusClientLayer
impl PrometheusClientLayer
Sourcepub fn builder() -> PrometheusClientLayerBuilder
pub fn builder() -> PrometheusClientLayerBuilder
Create a PrometheusClientLayerBuilder to set the configuration of metrics.
Trait Implementations§
Source§impl Clone for PrometheusClientLayer
impl Clone for PrometheusClientLayer
Source§fn clone(&self) -> PrometheusClientLayer
fn clone(&self) -> PrometheusClientLayer
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<A: Access> Layer<A> for PrometheusClientLayer
impl<A: Access> Layer<A> for PrometheusClientLayer
Source§type LayeredAccess = MetricsAccessor<A, PrometheusClientInterceptor>
type LayeredAccess = MetricsAccessor<A, PrometheusClientInterceptor>
The layered accessor that returned by this layer.
Source§fn layer(&self, inner: A) -> Self::LayeredAccess
fn layer(&self, inner: A) -> Self::LayeredAccess
Intercept the operations on the underlying storage.
Auto Trait Implementations§
impl Freeze for PrometheusClientLayer
impl !RefUnwindSafe for PrometheusClientLayer
impl Send for PrometheusClientLayer
impl Sync for PrometheusClientLayer
impl Unpin for PrometheusClientLayer
impl UnsafeUnpin for PrometheusClientLayer
impl !UnwindSafe for PrometheusClientLayer
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