refactor(middleware): add middleware to record metrics for request count and duration (#7803)

This commit is contained in:
Sanchith Hegde
2025-04-21 13:18:33 +05:30
committed by GitHub
parent f00f7a2aa3
commit 54a1719fe6
8 changed files with 106 additions and 91 deletions

View File

@ -10,7 +10,7 @@ use crate::{
events::api_logs::ApiEventMetric,
routes::{
app::{AppStateInfo, ReqState},
metrics, AppState, SessionState,
AppState, SessionState,
},
services::{self, api, authentication as auth, logger},
};
@ -44,18 +44,15 @@ where
let start_instant = Instant::now();
logger::info!(tag = ?Tag::BeginRequest, payload = ?payload);
let server_wrap_util_res = metrics::request::record_request_time_metric(
api::server_wrap_util(
&flow,
state.clone().into(),
request.headers(),
request,
payload,
func,
api_authentication,
lock_action,
),
let server_wrap_util_res = api::server_wrap_util(
&flow,
state.clone().into(),
request.headers(),
request,
payload,
func,
api_authentication,
lock_action,
)
.await
.map(|response| {