Support in-flight request age metrics for router (#16341)

This commit is contained in:
fzyzcjy
2026-01-04 07:38:53 +08:00
committed by GitHub
parent e139d2aa76
commit c88aaf22c7
8 changed files with 428 additions and 9 deletions
+7 -1
View File
@@ -654,7 +654,9 @@ pub fn build_app(
max_payload_size,
))
.layer(middleware::create_logging_layer())
.layer(middleware::HttpMetricsLayer::new())
.layer(middleware::HttpMetricsLayer::new(
app_state.context.inflight_tracker.clone(),
))
.layer(middleware::RequestIdLayer::new(request_id_headers))
.layer(create_cors_layer(cors_allowed_origins))
.fallback(sink_handler)
@@ -714,6 +716,10 @@ pub async fn startup(config: ServerConfig) -> Result<(), Box<dyn std::error::Err
AppContext::from_config(config.router_config.clone(), config.request_timeout_secs).await?,
);
if config.prometheus_config.is_some() {
app_context.inflight_tracker.start_sampler(20);
}
let weak_context = Arc::downgrade(&app_context);
let worker_job_queue = JobQueue::new(JobQueueConfig::default(), weak_context);
app_context