Skip to content

Commit

Permalink
feat(layer/otelmetrics): add OtelMetricsLayer (#5524)
Browse files Browse the repository at this point in the history
  • Loading branch information
andylokandy authored Jan 9, 2025
1 parent 86ba75d commit fc686ed
Show file tree
Hide file tree
Showing 6 changed files with 396 additions and 44 deletions.
27 changes: 15 additions & 12 deletions core/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ layers-prometheus-client = ["dep:prometheus-client"]
layers-fastrace = ["dep:fastrace"]
# Enable layers tracing support.
layers-tracing = ["dep:tracing"]
# Enable layers otelmetrics support.
layers-otel-metrics = ["opentelemetry/metrics"]
# Enable layers oteltrace support.
layers-otel-trace = ["dep:opentelemetry"]
layers-otel-trace = ["opentelemetry/trace"]
# Enable layers throttle support.
layers-throttle = ["dep:governor"]
# Enable layers await-tree support.
Expand Down Expand Up @@ -374,7 +376,7 @@ mime_guess = { version = "2.0.5", optional = true }
# for layers-fastrace
fastrace = { version = "0.7.1", optional = true }
# for layers-opentelemetry
opentelemetry = { version = "0.26", optional = true }
opentelemetry = { version = "0.27", optional = true }
# for layers-prometheus
prometheus = { version = "0.13", features = ["process"], optional = true }
# for layers-prometheus-client
Expand All @@ -395,17 +397,17 @@ dotenvy = "0.15"
fastrace = { version = "0.7", features = ["enable"] }
fastrace-jaeger = "0.7"
libtest-mimic = "0.8"
opentelemetry = { version = "0.26", default-features = false, features = [
"trace",
opentelemetry = { version = "0.27", default-features = false, features = [
"trace",
] }
opentelemetry-otlp = "0.26"
opentelemetry_sdk = "0.26"
opentelemetry-otlp = "0.27"
opentelemetry_sdk = { version = "0.27", features = ["rt-tokio"] }
pretty_assertions = "1"
rand = "0.8"
sha2 = "0.10"
size = "0.4"
tokio = { version = "1.27", features = ["fs", "macros", "rt-multi-thread"] }
tracing-opentelemetry = "0.27.0"
tracing-opentelemetry = "0.28.0"
tracing-subscriber = { version = "0.3", features = [
"env-filter",
"tracing-log",
Expand Down
40 changes: 21 additions & 19 deletions core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,25 +105,26 @@ OpenDAL supports the following storage [services](https://docs.rs/opendal/latest

OpenDAL supports the following storage [layers](https://docs.rs/opendal/latest/opendal/layers/index.html) to extend the behavior:

| Name | Depends | Description |
|---------------------------|------------------------|---------------------------------------------------------------------------------------|
| [`AsyncBacktraceLayer`] | [async-backtrace] | Add Efficient, logical 'stack' traces of async functions for the underlying services. |
| [`AwaitTreeLayer`] | [await-tree] | Add a Instrument await-tree for actor-based applications to the underlying services. |
| [`BlockingLayer`] | [tokio] | Add blocking API support for non-blocking services. |
| [`ChaosLayer`] | [rand] | Inject chaos into underlying services for robustness test. |
| [`ConcurrentLimitLayer`] | [tokio] | Add concurrent request limit. |
| [`DtraceLayer`] | [probe] | Support User Statically-Defined Tracing(aka USDT) on Linux |
| [`LoggingLayer`] | [log] | Add log for every operations. |
| [`MetricsLayer`] | [metrics] | Add metrics for every operations. |
| [`MimeGuessLayer`] | [mime_guess] | Add `Content-Type` automatically based on the file extension in the operation path. |
| [`FastraceLayer`] | [fastrace] | Add fastrace for every operations. |
| [`OtelTraceLayer`] | [opentelemetry::trace] | Add opentelemetry::trace for every operations. |
| [`PrometheusClientLayer`] | [prometheus_client] | Add prometheus metrics for every operations. |
| [`PrometheusLayer`] | [prometheus] | Add prometheus metrics for every operations. |
| [`RetryLayer`] | [backon] | Add retry for temporary failed operations. |
| [`ThrottleLayer`] | [governor] | Add a bandwidth rate limiter to the underlying services. |
| [`TimeoutLayer`] | [tokio] | Add timeout for every operations to avoid slow or unexpected hang operations. |
| [`TracingLayer`] | [tracing] | Add tracing for every operations. |
| Name | Depends | Description |
|---------------------------|--------------------------|---------------------------------------------------------------------------------------|
| [`AsyncBacktraceLayer`] | [async-backtrace] | Add Efficient, logical 'stack' traces of async functions for the underlying services. |
| [`AwaitTreeLayer`] | [await-tree] | Add a Instrument await-tree for actor-based applications to the underlying services. |
| [`BlockingLayer`] | [tokio] | Add blocking API support for non-blocking services. |
| [`ChaosLayer`] | [rand] | Inject chaos into underlying services for robustness test. |
| [`ConcurrentLimitLayer`] | [tokio] | Add concurrent request limit. |
| [`DtraceLayer`] | [probe] | Support User Statically-Defined Tracing(aka USDT) on Linux |
| [`LoggingLayer`] | [log] | Add log for every operations. |
| [`MetricsLayer`] | [metrics] | Add metrics for every operations. |
| [`MimeGuessLayer`] | [mime_guess] | Add `Content-Type` automatically based on the file extension in the operation path. |
| [`FastraceLayer`] | [fastrace] | Add fastrace for every operations. |
| [`OtelMetricsLayer`] | [opentelemetry::metrics] | Add opentelemetry::metrics for every operations. |
| [`OtelTraceLayer`] | [opentelemetry::trace] | Add opentelemetry::trace for every operations. |
| [`PrometheusClientLayer`] | [prometheus_client] | Add prometheus metrics for every operations. |
| [`PrometheusLayer`] | [prometheus] | Add prometheus metrics for every operations. |
| [`RetryLayer`] | [backon] | Add retry for temporary failed operations. |
| [`ThrottleLayer`] | [governor] | Add a bandwidth rate limiter to the underlying services. |
| [`TimeoutLayer`] | [tokio] | Add timeout for every operations to avoid slow or unexpected hang operations. |
| [`TracingLayer`] | [tracing] | Add tracing for every operations. |

[`AsyncBacktraceLayer`]: https://docs.rs/opendal/latest/opendal/layers/struct.AsyncBacktraceLayer.html
[async-backtrace]: https://github.com/tokio-rs/async-backtrace
Expand All @@ -144,6 +145,7 @@ OpenDAL supports the following storage [layers](https://docs.rs/opendal/latest/o
[mime_guess]: https://github.com/abonander/mime_guess
[`FastraceLayer`]: https://docs.rs/opendal/latest/opendal/layers/struct.FastraceLayer.html
[fastrace]: https://github.com/fastracelabs/fastrace
[`OtelMetricsLayer`]: https://docs.rs/opendal/latest/opendal/layers/struct.OtelMetricsLayer.html
[`OtelTraceLayer`]: https://docs.rs/opendal/latest/opendal/layers/struct.OtelTraceLayer.html
[opentelemetry::trace]: https://docs.rs/opentelemetry/latest/opentelemetry/trace/index.html
[`PrometheusClientLayer`]: https://docs.rs/opendal/latest/opendal/layers/struct.PrometheusClientLayer.html
Expand Down
5 changes: 5 additions & 0 deletions core/src/layers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ mod fastrace;
#[cfg(feature = "layers-fastrace")]
pub use self::fastrace::FastraceLayer;

#[cfg(feature = "layers-otel-metrics")]
mod otelmetrics;
#[cfg(feature = "layers-otel-metrics")]
pub use self::otelmetrics::OtelMetricsLayer;

#[cfg(feature = "layers-otel-trace")]
mod oteltrace;
#[cfg(feature = "layers-otel-trace")]
Expand Down
Loading

0 comments on commit fc686ed

Please sign in to comment.