Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix metrics not shutting down if there are open connections #6220

Merged
merged 3 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions prdoc/pr_6220.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: Improve `CheckMetadataHash` transaction extension weight and logic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

title needs to be updated, to reference the actual fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙈 thanks


doc:
- audience: Runtime Dev
description: |
Fix prometheus metrics not shutting down if there are open connections

crates:
- name: substrate-prometheus-endpoint
bump: patch
2 changes: 1 addition & 1 deletion substrate/utils/prometheus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
http-body-util = { workspace = true }
hyper = { features = ["http1", "server"], workspace = true }
hyper-util = { features = ["server-auto", "tokio"], workspace = true }
hyper-util = { features = ["server-auto", "server-graceful", "tokio"], workspace = true }
log = { workspace = true, default-features = true }
prometheus = { workspace = true }
thiserror = { workspace = true }
Expand Down
2 changes: 2 additions & 0 deletions substrate/utils/prometheus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ async fn init_prometheus_with_listener(
log::info!(target: "prometheus", "〽️ Prometheus exporter started at {}", listener.local_addr()?);

let server = hyper_util::server::conn::auto::Builder::new(hyper_util::rt::TokioExecutor::new());
let graceful = hyper_util::server::graceful::GracefulShutdown::new();

loop {
let io = match listener.accept().await {
Expand All @@ -120,6 +121,7 @@ async fn init_prometheus_with_listener(
hyper::service::service_fn(move |req| request_metrics(req, registry.clone())),
)
.into_owned();
let conn = graceful.watch(conn);

tokio::spawn(async move {
if let Err(err) = conn.await {
Expand Down
Loading