OpenDAL has native support for metrics.
MetricsLayer will add metrics for every operation.
Enable metrics layer requires enable feature
use anyhow::Result; use opendal::layers::MetricsLayer; use opendal::Operator; use opendal::Scheme; let _ = Operator::from_env(Scheme::Fs) .expect("must init") .layer(MetricsLayer);
OpenDAL is using
metrics for metrics internally.
To enable metrics output, please enable one of the exporters that
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");