Struct opendal::layers::MetricsLayer
source · pub struct MetricsLayer;
Expand description
Add metrics for every operations.
Metrics
opendal_requests_total
: Total request numbers.opendal_requests_duration_seconds
: Request duration seconds.opendal_errors_total
: Total error numbers.opendal_bytes_total
: bytes read/write from/to underlying storage.
Labels
metrics will carry the following labels
service
: Service name fromScheme
operation
: Operation name fromOperation
error
:ErrorKind
received by requests
Notes
Please make sure the exporter has been pulled in regular time.
Otherwise, the histogram data collected by requests_duration_seconds
could result in OOM.
Examples
use anyhow::Result;
use opendal::layers::MetricsLayer;
use opendal::services;
use opendal::Operator;
let _ = Operator::new(services::Memory::default())
.expect("must init")
.layer(MetricsLayer)
.finish();
Output
OpenDAL is using metrics
for metrics internally.
To enable metrics output, please enable one of the exporters that metrics
supports.
Take metrics_exporter_prometheus
as an example:
ⓘ
let builder = PrometheusBuilder::new();
builder.install().expect("failed to install recorder/exporter");
let handle = builder.install_recorder().expect("failed to install recorder");
let (recorder, exporter) = builder.build().expect("failed to build recorder/exporter");
let recorder = builder.build_recorder().expect("failed to build recorder");
Trait Implementations§
source§impl Clone for MetricsLayer
impl Clone for MetricsLayer
source§fn clone(&self) -> MetricsLayer
fn clone(&self) -> MetricsLayer
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for MetricsLayer
impl Debug for MetricsLayer
source§impl<A: Accessor> Layer<A> for MetricsLayer
impl<A: Accessor> Layer<A> for MetricsLayer
§type LayeredAccessor = MetricsAccessor<A>
type LayeredAccessor = MetricsAccessor<A>
The layered accessor that return by this layer.
source§fn layer(&self, inner: A) -> Self::LayeredAccessor
fn layer(&self, inner: A) -> Self::LayeredAccessor
Intercept the operations on the underlying storage.