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
dragonball: add tracing feature for dragonball #7831
dragonball: add tracing feature for dragonball #7831
Conversation
Can one of the admins verify this patch? |
5bb62da
to
75501b4
Compare
src/dragonball/Cargo.toml
Outdated
tracing = "0.1.37" | ||
tracing-opentelemetry = "0.18.0" | ||
opentelemetry = { version = "0.18.0", features = [ "trace", "rt-tokio"] } | ||
opentelemetry-jaeger = { version = "0.17.0", features = ["rt-tokio", "hyper_collector_client", "collector_client","rt-tokio-current-thread"] } |
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.
add a space after ','
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.
Fixed.
src/dragonball/src/event_manager.rs
Outdated
impl std::fmt::Debug for EventManager { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
f.debug_struct("EventManager") | ||
.field("epoll_mgr", &self.epoll_mgr.type_id()) |
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.
Do we need to get the type_id of epoll mgr?
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.
Unnecessary, fixed.
src/dragonball/src/tracer.rs
Outdated
pub enum DragonballTraceError { | ||
/// verify jaeger config failed. | ||
#[error("config verify failed: {0}")] | ||
ConfigVerifyFailed(anyhow::Error), |
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.
add #source to expand the error stack, and we shouldn't use anyhow in dragonball
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.
Fixed.
src/dragonball/src/tracer.rs
Outdated
fn eq(&self, other: &Self) -> bool { | ||
if self.sid == other.sid | ||
&& self.jaeger_endpoint == other.jaeger_endpoint | ||
&& self.jaeger_user == other.jaeger_user |
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.
self.sid == other.sid
&& self.jaeger_endpoint == other.jaeger_endpoint
&& self.jaeger_user == other.jaeger_user
&& self.jaeger_password == other.jaeger_password
is enough
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.
Done.
src/dragonball/src/tracer.rs
Outdated
} | ||
} | ||
|
||
impl Eq for TraceConfigInfo {} |
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.
use derive
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.
It will encounter a compile error: the trait std::cmp::Eq
is not implemented for (dyn tracing::Subscriber + Send + Sync + 'static)
src/dragonball/src/tracer.rs
Outdated
.with_password(config.jaeger_password) | ||
.with_hyper() | ||
.install_batch(opentelemetry::runtime::Tokio) | ||
.expect("Tracer: create jaeger tracer err"); |
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.
return error instead of expect
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.
This code is running in the closure of block_on
function, we can't process the error outside the closure. I add a comment here.
src/dragonball/src/tracer.rs
Outdated
|
||
/// tracing feature for app. | ||
pub fn setup_tracing(&mut self, config: TraceConfigInfo) -> Result<(), DragonballTraceError> { | ||
if !self.enable_tracing { |
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.
if self.enable_tracing {return Ok(())}
xxx
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.
Fixed.
src/dragonball/src/tracer.rs
Outdated
|
||
#[cfg(test)] | ||
mod tests { | ||
use opentelemetry::global; |
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.
clear up use statement
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.
Fixed.
src/dragonball/src/vmm.rs
Outdated
return v.stop(EXIT_CODE_OK as i32); | ||
let ret = v.stop(EXIT_CODE_OK as i32); | ||
let tracer_mutex = service.tracer(); | ||
let mut tracer = tracer_mutex.lock().unwrap(); |
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.
tracer_gruad
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.
Fixed.
@@ -194,6 +203,17 @@ impl Vmm { | |||
} | |||
} | |||
|
|||
impl std::fmt::Debug for Vmm { |
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.
why you need implement debug for vmm?
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.
It's needed for macro instrument
. The instrument
collects the arguments of function and outputs them to tracing info.
2be3729
to
76717af
Compare
76717af
to
c2970d8
Compare
c2970d8
to
76630ee
Compare
1b2c56a
to
72141bb
Compare
tracer | ||
.setup_tracing(trace_info) | ||
.map(|_| VmmData::Empty) | ||
.map_err(|_| VmmActionError::TracingFailed) |
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.
Don't discard inner errors
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.
Fixed.
tracer | ||
.end_tracing() | ||
.map(|_| VmmData::Empty) | ||
.map_err(|_| VmmActionError::TracingFailed) |
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.
Don't discard inner errors
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.
Fixed.
@@ -760,6 +817,16 @@ impl VmmService { | |||
} | |||
} | |||
|
|||
impl std::fmt::Debug for VmmService { |
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.
Try to use this: https://mcarton.github.io/rust-derivative/latest/Debug.html
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.
same below
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.
Lesson learned. I use it for TraceInfo
. But I delete the Debug trait for VmmService
since we don't need to output the information of VmmService
in tracing.
src/dragonball/src/tracer.rs
Outdated
} | ||
} | ||
|
||
impl Eq for TraceInfo {} |
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.
Use derive directly
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.
Fixed it with derivative.
src/dragonball/src/tracer.rs
Outdated
} | ||
} | ||
|
||
impl PartialEq for TraceInfo { |
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.
Why do you need to implement PartialEq
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.
TraceInfo
is used in VmmAction::SetHypervisorTracing(TraceInfo)
and VmmAction
implements the PartialEq. This is also the reason why I added the sid
field to TraceInfo
.
src/dragonball/src/tracer.rs
Outdated
|
||
/// Return whether the tracing is enabled, enabled by [`setup_tracing`] | ||
pub fn enabled(&self) -> bool { | ||
self.tracing_on |
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.
just name this field to enabled
?
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.
Done.
c9a67fc
to
7e5a3a9
Compare
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.
LGTM
/test |
7e5a3a9
to
3cc00b8
Compare
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.
I recommand that you write a document for how to use the trace functionality under /src/dragonball/docs
including how to use and how runtime-rs could use the tracing data from dragonball.
You could choose to do that in another PR.
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.
thanks, a few comments
src/dragonball/src/tracer.rs
Outdated
} | ||
|
||
#[test] | ||
fn test_tracing_in_lib() { |
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.
Is that more like a integration test
instead of unit test
?
Will that be too much to create a JAEGER service every time we run unit test?
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.
Yes, this is more like an example and I have removed it. Actually, opentelemetry_jaeger
just creates a request to export the tracing info to JAEGER.
Besides, did you see how runtime-rs code and have a plan that how could they use your new two actions? |
Yes, I saw. I will new a PR to support dragonball tracing for runtime-rs after this PR is merged. |
I will support the dargonball tracing for |
This PR adds the tracing capability for dragonball and it depends on the tracing::Subscriber of the upper layer. Fixes: kata-containers#7249 Signed-off-by: Songqian Li <mail@lisongqian.cn>
3cc00b8
to
2f533c3
Compare
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.
LGTM, also I think that jaeger example could put into dbs-cli if that makes sense.
/test |
This PR add tracing feature for dragonball.
Fixes: #7249
Signed-off-by: lisongqian mail@lisongqian.cn