Skip to content

Commit

Permalink
fix: replace opendal PrometheusLayer (#2861)
Browse files Browse the repository at this point in the history
* fix: replace opendal `PrometheusLayer`

* chore: add docs on `PrometheusMetricsLayer`

* chore: fix code advice

* chore: fix bug on `PrometheusMetricsLayer`
  • Loading branch information
Taylor-lagrange authored Dec 5, 2023
1 parent b3ffe5c commit aa89d9d
Show file tree
Hide file tree
Showing 7 changed files with 568 additions and 23 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

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

3 changes: 0 additions & 3 deletions src/datanode/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ version.workspace = true
edition.workspace = true
license.workspace = true

[features]
testing = []

[dependencies]
api.workspace = true
arrow-flight.workspace = true
Expand Down
20 changes: 3 additions & 17 deletions src/datanode/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,9 @@ pub(crate) async fn new_object_store(opts: &DatanodeOptions) -> Result<ObjectSto
.with_error_level(Some("debug"))
.expect("input error level must be valid"),
)
.layer(TracingLayer);

// In the test environment, multiple datanodes will be started in the same process.
// If each datanode registers Prometheus metric when it starts, it will cause the program to crash. (Because the same metric is registered repeatedly.)
// So the Prometheus metric layer is disabled in the test environment.
#[cfg(feature = "testing")]
return Ok(store);

#[cfg(not(feature = "testing"))]
{
let registry = prometheus::default_registry();
Ok(
store.layer(object_store::layers::PrometheusLayer::with_registry(
registry.clone(),
)),
)
}
.layer(TracingLayer)
.layer(object_store::layers::PrometheusMetricsLayer);
Ok(store)
}

async fn create_object_store_with_cache(
Expand Down
1 change: 0 additions & 1 deletion src/object-store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ md5 = "0.7"
moka = { workspace = true, features = ["future"] }
opendal = { version = "0.40", features = [
"layers-tracing",
"layers-prometheus",
] }
prometheus.workspace = true
snafu.workspace = true
Expand Down
2 changes: 2 additions & 0 deletions src/object-store/src/layers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// limitations under the License.

mod lru_cache;
mod prometheus;

pub use lru_cache::*;
pub use opendal::layers::*;
pub use prometheus::PrometheusMetricsLayer;
Loading

0 comments on commit aa89d9d

Please sign in to comment.