Skip to content

Commit

Permalink
make usdt an optional dependency (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahl authored May 20, 2022
1 parent 53106a8 commit b4ca959
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
1 change: 1 addition & 0 deletions dropshot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ features = [ "full" ]

[dependencies.usdt]
version = "0.3.2"
optional = true
default-features = false

[dependencies.uuid]
Expand Down
1 change: 1 addition & 0 deletions dropshot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ pub(crate) struct ResponseInfo {
message: String,
}

#[cfg(feature = "usdt-probes")]
#[usdt::provider(provider = "dropshot")]
mod probes {
use crate::{RequestInfo, ResponseInfo};
Expand Down
37 changes: 19 additions & 18 deletions dropshot/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,25 +162,26 @@ impl<C: ServerContext> HttpServerStarter<C> {
};
info!(self.app_state.log, "listening");

let probe_registration = if cfg!(feature = "usdt-probes") {
match usdt::register_probes() {
Ok(_) => {
debug!(
self.app_state.log,
"successfully registered DTrace USDT probes"
);
ProbeRegistration::Succeeded
}
Err(e) => {
let msg = e.to_string();
error!(
self.app_state.log,
"failed to register DTrace USDT probes: {}", msg
);
ProbeRegistration::Failed(msg)
}
#[cfg(feature = "usdt-probes")]
let probe_registration = match usdt::register_probes() {
Ok(_) => {
debug!(
self.app_state.log,
"successfully registered DTrace USDT probes"
);
ProbeRegistration::Succeeded
}
} else {
Err(e) => {
let msg = e.to_string();
error!(
self.app_state.log,
"failed to register DTrace USDT probes: {}", msg
);
ProbeRegistration::Failed(msg)
}
};
#[cfg(not(feature = "usdt-probes"))]
let probe_registration = {
debug!(
self.app_state.log,
"DTrace USDT probes compiled out, not registering"
Expand Down

0 comments on commit b4ca959

Please sign in to comment.