Skip to content

Commit cc2425e

Browse files
feat: added some info logs and prometheus health check on startup
1 parent 573b687 commit cc2425e

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

asap-query-engine/src/drivers/query/servers/http.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ async fn process_query_request(
217217
total_duration.as_secs_f64() * 1000.0
218218
);
219219
debug!("=== RETURNING SUCCESS RESPONSE ===");
220+
info!(
221+
"query='{}' destination=asap asap_latency_ms={:.2} total_latency_ms={:.2}",
222+
parsed_request.query,
223+
query_duration.as_secs_f64() * 1000.0,
224+
total_duration.as_secs_f64() * 1000.0
225+
);
220226

221227
match state
222228
.adapter
@@ -238,6 +244,11 @@ async fn process_query_request(
238244
// Step 4: Handle unsupported query using fallback client
239245
if let Some(fallback) = &state.fallback {
240246
debug!("Query not supported locally, forwarding to fallback");
247+
info!(
248+
"query='{}' destination=prometheus total_latency_ms={:.2}",
249+
parsed_request.query,
250+
total_duration.as_secs_f64() * 1000.0
251+
);
241252
// Fallback client handles the HTTP call and returns formatted response
242253
match fallback
243254
.execute_query_with_headers(parsed_request, headers)
@@ -248,6 +259,11 @@ async fn process_query_request(
248259
}
249260
} else {
250261
debug!("Query not supported and forwarding disabled, returning error");
262+
info!(
263+
"query='{}' destination=none_unsupported total_latency_ms={:.2}",
264+
parsed_request.query,
265+
total_duration.as_secs_f64() * 1000.0
266+
);
251267
// Adapter formats the unsupported query error for its protocol
252268
match state.adapter.format_unsupported_query_response().await {
253269
Ok(json) => json.into_response(),

asap-query-engine/src/main.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,40 @@ async fn main() -> Result<()> {
403403
adapter_config,
404404
};
405405

406+
// Verify Prometheus is reachable before starting
407+
{
408+
let client = reqwest::Client::new();
409+
let health_url = format!(
410+
"{}/api/v1/status/runtimeinfo",
411+
args.prometheus_server.trim_end_matches('/')
412+
);
413+
match client
414+
.get(&health_url)
415+
.timeout(std::time::Duration::from_secs(5))
416+
.send()
417+
.await
418+
{
419+
Ok(resp) if resp.status().is_success() => {
420+
info!("Prometheus reachable at {}", args.prometheus_server);
421+
}
422+
Ok(resp) => {
423+
error!(
424+
"Prometheus at {} returned HTTP {} — cannot start",
425+
args.prometheus_server,
426+
resp.status()
427+
);
428+
std::process::exit(1);
429+
}
430+
Err(e) => {
431+
error!(
432+
"Cannot reach Prometheus at {}: {}",
433+
args.prometheus_server, e
434+
);
435+
std::process::exit(1);
436+
}
437+
}
438+
}
439+
406440
let query_tracker = if args.enable_query_tracker {
407441
use query_engine_rust::planner_client::{LocalPlannerClient, PlannerResult};
408442
use query_engine_rust::QueryTrackerConfig;

0 commit comments

Comments
 (0)