Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
koushiro committed Sep 3, 2024
1 parent 7cae089 commit 04d64a5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
11 changes: 11 additions & 0 deletions core/src/layers/observe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@
//! OpenDAL Observability Layer
//!
//! This module offers essential components to facilitate the implementation of observability in OpenDAL.
//!
//! # Prometheus Metrics
//!
//! These metrics are essential for understanding the behavior and performance of our applications.
//!
//! | Metric Name | Type | Description | Labels |
//! |------------------------------|-----------|--------------------------------------------------------------|-------------------------------------------------|
//! | operation_duration_seconds | Histogram | Histogram of time spent during opendal operations | scheme, namespace, root, operation, path |
//! | operation_bytes. | Histogram | Histogram of the bytes transferred during opendal operations | scheme, operation, root, operation, path |
//! | operation_errors_total | Counter | Error counter during opendal operations | scheme, operation, root, operation, path, error |
//!

mod metrics;

Expand Down
32 changes: 13 additions & 19 deletions core/src/layers/prometheus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,9 @@ use crate::*;
///
/// # Prometheus Metrics
///
/// In this section, we will introduce three metrics that are currently being exported by our project. These metrics are essential for understanding the behavior and performance of our applications.
///
///
/// | Metric Name | Type | Description | Labels |
/// |-------------------------|----------|---------------------------------------------------|---------------------|
/// | requests_total | Counter | Total times of 'create' operation being called | scheme, operation |
/// | requests_duration_seconds | Histogram | Histogram of the time spent on specific operation | scheme, operation |
/// | bytes_total | Histogram | Total size | scheme, operation |
///
/// 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](https://prometheus.io/docs/introduction/overview/).
///
/// # Histogram Configuration
///
/// The metric buckets for these histograms are automatically generated based on the `exponential_buckets(0.01, 2.0, 16)` configuration.
///
/// # Examples
///
/// ```no_run
Expand Down Expand Up @@ -99,6 +87,12 @@ pub struct PrometheusLayer {
impl PrometheusLayer {
/// Create a [`PrometheusLayerBuilder`] to set the configuration of metrics.
///
/// # Default Configuration
///
/// - `operation_duration_seconds_buckets`: `exponential_buckets(0.01, 2.0, 16)`
/// - `operation_bytes_buckets`: `exponential_buckets(1.0, 2.0, 16)`
/// - `path_label`: `0`
///
/// # Example
///
/// ```no_run
Expand All @@ -121,7 +115,7 @@ impl PrometheusLayer {
/// PrometheusLayer::builder()
/// .operation_duration_seconds_buckets(duration_seconds_buckets)
/// .operation_bytes_buckets(bytes_buckets)
/// .path_label(1)
/// .path_label(0)
/// .register(registry)
/// .expect("register metrics successfully")
/// )
Expand Down Expand Up @@ -427,7 +421,7 @@ impl observe::MetricsIntercept for PrometheusInterceptor {
scheme,
namespace: &namespace,
root: &root,
op,
operation: op,
error: None,
path,
}
Expand All @@ -451,7 +445,7 @@ impl observe::MetricsIntercept for PrometheusInterceptor {
scheme,
namespace: &namespace,
root: &root,
op,
operation: op,
error: None,
path,
}
Expand All @@ -475,7 +469,7 @@ impl observe::MetricsIntercept for PrometheusInterceptor {
scheme,
namespace: &namespace,
root: &root,
op,
operation: op,
error: Some(error),
path,
}
Expand All @@ -489,7 +483,7 @@ struct OperationLabels<'a> {
scheme: Scheme,
namespace: &'a str,
root: &'a str,
op: Operation,
operation: Operation,
path: &'a str,
error: Option<ErrorKind>,
}
Expand Down Expand Up @@ -529,7 +523,7 @@ impl<'a> OperationLabels<'a> {
self.scheme.into_static(),
self.namespace,
self.root,
self.op.into_static(),
self.operation.into_static(),
]);

if let Some(path) = observe::path_label_value(self.path, path_label_level) {
Expand Down

0 comments on commit 04d64a5

Please sign in to comment.