-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(tracing): add minitrace to RisingLight #550
Conversation
After some offline discussions, I think it's better to define a |
I think current implementation is too intrusive in that it changes the signature of the entire executor builder. IMO it's better to hide the trace works outside the core executors and do it in a unified way (not each time we add a new executor), which can be achieved by proxying the visitor. Also we can attach any common modifiers here according to the build options, such as diff --git a/src/executor/mod.rs b/src/executor/mod.rs
index cf93b53..e5040c3 100644
--- a/src/executor/mod.rs
+++ b/src/executor/mod.rs
@@ -207,6 +207,11 @@ impl ExecutorExt for BoxedExecutor {
}
impl PlanVisitor<BoxedExecutor> for ExecutorBuilder {
+ fn visit(&mut self, plan: PlanRef) -> Option<BoxedExecutor> {
+ println!("before");
+ // `trace` is a modifier here that do the trace.
+ self.visit_inner(plan).trace()
+ }
+
fn visit_dummy(&mut self, _plan: &Dummy) -> Option<BoxedExecutor> {
Some(DummyScanExecutor.execute())
}
diff --git a/src/optimizer/plan_visitor.rs b/src/optimizer/plan_visitor.rs
index 6f1d82d..ac173f7 100644
--- a/src/optimizer/plan_visitor.rs
+++ b/src/optimizer/plan_visitor.rs
@@ -11,7 +11,11 @@ macro_rules! def_visitor {
/// The visitor for plan nodes. visit all children and return the ret value of the left most child.
pub trait PlanVisitor<R> {
paste! {
- fn visit(&mut self, plan: PlanRef) -> Option<R>{
+ fn visit(&mut self, plan: PlanRef) -> Option<R> {
+ self.visit_inner(plan)
+ }
+
+ fn visit_inner(&mut self, plan: PlanRef) -> Option<R> {
match plan.node_type() {
$(
crate::optimizer::plan_nodes::PlanNodeType::$node => self.[<visit_ $node:snake>](plan.downcast_ref::<$node>().unwrap()), BTW, minitrace is not suitable for tracing under such execution model as it does not support the async enter of the span tree unless we modify the executor's interface. |
I think it can. We propose to add a |
I see. |
Signed-off-by: Xinpeng Wei <xinpeng@singularity-data.com>
561e31d
to
c9915dc
Compare
Signed-off-by: Xinpeng Wei <xinpeng@singularity-data.com>
…#368) Signed-off-by: Xinpeng Wei <xinpeng@singularity-data.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest LGTM. Any ideas from cc @zhongzc @breeswish? Thanks!
src/db.rs
Outdated
for chunk in &output { | ||
debug!("output:\n{}", chunk); | ||
} | ||
if !column_names.is_empty() && !output.is_empty() { | ||
output[0].set_header(column_names); | ||
} | ||
outputs.push(Chunk::new(output)); | ||
|
||
let records: Vec<SpanRecord> = block_on(collector.collect()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should use .await
instead of block_on
.
for chunk in &output { | ||
debug!("output:\n{}", chunk); | ||
} | ||
if !column_names.is_empty() && !output.is_empty() { | ||
output[0].set_header(column_names); | ||
} | ||
outputs.push(Chunk::new(output)); | ||
|
||
let records: Vec<SpanRecord> = block_on(collector.collect()); | ||
println!("{records:#?}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make it an optional feature? Either using https://doc.rust-lang.org/cargo/reference/features.html and #[cfg(feature = enable_tracing)]
, or use cli arg to specify whether to enable it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotcha
Signed-off-by: Xinpeng Wei <xinpeng@singularity-data.com>
Signed-off-by: Xinpeng Wei <xinpeng@singularity-data.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LGTM, good work!
close #368
Signed-off-by: Xinpeng Wei xinpeng@singularity-data.com