http: upgrade metrics crate to 0.22

This commit is contained in:
Joakim Frostegård 2024-01-25 00:03:05 +01:00
parent fe6a7ef8b5
commit c7f7f010ca
6 changed files with 90 additions and 161 deletions

View file

@ -25,9 +25,6 @@ use crate::common::*;
use crate::config::Config;
use crate::workers::socket::connection::{run_connection, ConnectionError};
#[cfg(feature = "metrics")]
thread_local! { static WORKER_INDEX: ::std::cell::Cell<usize> = Default::default() }
struct ConnectionHandle {
close_conn_sender: LocalSender<()>,
valid_until: Rc<RefCell<ValidUntil>>,
@ -44,9 +41,6 @@ pub async fn run_socket_worker(
server_start_instant: ServerStartInstant,
worker_index: usize,
) {
#[cfg(feature = "metrics")]
WORKER_INDEX.with(|index| index.set(worker_index));
let config = Rc::new(config);
let access_list = state.access_list;
@ -93,12 +87,14 @@ pub async fn run_socket_worker(
)
async move {
#[cfg(feature = "metrics")]
::metrics::increment_gauge!(
let active_connections_gauge = ::metrics::gauge!(
"aquatic_active_connections",
1.0,
"worker_index" => worker_index.to_string(),
);
#[cfg(feature = "metrics")]
active_connections_gauge.increment(1.0);
let f1 = async { run_connection(
config,
access_list,
@ -107,6 +103,7 @@ pub async fn run_socket_worker(
opt_tls_config,
valid_until.clone(),
stream,
worker_index,
).await
};
let f2 = async {
@ -118,11 +115,7 @@ pub async fn run_socket_worker(
let result = race(f1, f2).await;
#[cfg(feature = "metrics")]
::metrics::decrement_gauge!(
"aquatic_active_connections",
1.0,
"worker_index" => worker_index.to_string(),
);
active_connections_gauge.decrement(1.0);
match result {
Ok(()) => (),