Skip to content

Commit 7cc80b2

Browse files
authored
feat(cubesql): Report rewrite start/success events (#9917)
Signed-off-by: Alex Qyoun-ae <[email protected]>
1 parent a70cde9 commit 7cc80b2

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

rust/cubesql/cubesql/src/compile/query_engine.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,22 @@ pub trait QueryEngine {
174174
)
175175
.map_err(|e| CompilationError::internal(e.to_string()))?;
176176

177+
let rewriting_start = SystemTime::now();
178+
if let Some(span_id) = span_id.as_ref() {
179+
if let Some(auth_context) = state.auth_context() {
180+
self.transport_ref()
181+
.log_load_state(
182+
Some(span_id.clone()),
183+
auth_context,
184+
state.get_load_request_meta("sql"),
185+
"SQL API Plan Rewrite".to_string(),
186+
serde_json::json!({}),
187+
)
188+
.await
189+
.map_err(|e| CompilationError::internal(e.to_string()))?;
190+
}
191+
}
192+
177193
let mut finalized_graph = self
178194
.compiler_cache_ref()
179195
.rewrite(
@@ -267,6 +283,23 @@ pub trait QueryEngine {
267283

268284
let rewrite_plan = result?;
269285

286+
if let Some(span_id) = span_id.as_ref() {
287+
if let Some(auth_context) = state.auth_context() {
288+
self.transport_ref()
289+
.log_load_state(
290+
Some(span_id.clone()),
291+
auth_context,
292+
state.get_load_request_meta("sql"),
293+
"SQL API Plan Rewrite Success".to_string(),
294+
serde_json::json!({
295+
"duration": rewriting_start.elapsed().unwrap().as_millis() as u64,
296+
}),
297+
)
298+
.await
299+
.map_err(|e| CompilationError::internal(e.to_string()))?;
300+
}
301+
}
302+
270303
// DF optimizes logical plan (second time) on physical plan creation
271304
// It's not safety to use all optimizers from DF for OLAP queries, because it will lead to errors
272305
// From another side, 99% optimizers cannot optimize anything

0 commit comments

Comments
 (0)