Skip to content

Commit 40f5884

Browse files
committed
add Query Execution metric in flight query
1 parent 82ea53d commit 40f5884

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

server/src/handlers/airplane.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use chrono::Utc;
66
use datafusion::common::tree_node::TreeNode;
77
use std::net::SocketAddr;
88
use std::sync::Arc;
9+
use std::time::Instant;
910

1011
use futures_util::{Future, TryFutureExt};
1112

@@ -16,6 +17,7 @@ use crate::event::commit_schema;
1617
use crate::handlers::http::cluster::get_ingestor_info;
1718
use crate::handlers::http::fetch_schema;
1819
use crate::handlers::http::ingest::push_logs_unchecked;
20+
use crate::metrics::QUERY_EXECUTE_TIME;
1921
use crate::option::{Mode, CONFIG};
2022

2123
use crate::handlers::livetail::cross_origin_config;
@@ -189,6 +191,7 @@ impl FlightService for AirServiceImpl {
189191
Status::permission_denied("User Does not have permission to access this")
190192
})?;
191193

194+
let time = Instant::now();
192195
let (results, _) = query
193196
.execute(stream_name.clone())
194197
.await
@@ -221,6 +224,12 @@ impl FlightService for AirServiceImpl {
221224
event.clear(&stream_name);
222225
}
223226
}
227+
228+
let time = time.elapsed().as_secs_f64();
229+
QUERY_EXECUTE_TIME
230+
.with_label_values(&["flight-query", &stream_name])
231+
.observe(time);
232+
224233
Ok(Response::new(Box::pin(output) as Self::DoGetStream))
225234
}
226235

0 commit comments

Comments
 (0)