Skip to content

Commit b4ca959

Browse files
authored
make usdt an optional dependency (#354)
1 parent 53106a8 commit b4ca959

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

dropshot/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ features = [ "full" ]
6060

6161
[dependencies.usdt]
6262
version = "0.3.2"
63+
optional = true
6364
default-features = false
6465

6566
[dependencies.uuid]

dropshot/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ pub(crate) struct ResponseInfo {
578578
message: String,
579579
}
580580

581+
#[cfg(feature = "usdt-probes")]
581582
#[usdt::provider(provider = "dropshot")]
582583
mod probes {
583584
use crate::{RequestInfo, ResponseInfo};

dropshot/src/server.rs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -162,25 +162,26 @@ impl<C: ServerContext> HttpServerStarter<C> {
162162
};
163163
info!(self.app_state.log, "listening");
164164

165-
let probe_registration = if cfg!(feature = "usdt-probes") {
166-
match usdt::register_probes() {
167-
Ok(_) => {
168-
debug!(
169-
self.app_state.log,
170-
"successfully registered DTrace USDT probes"
171-
);
172-
ProbeRegistration::Succeeded
173-
}
174-
Err(e) => {
175-
let msg = e.to_string();
176-
error!(
177-
self.app_state.log,
178-
"failed to register DTrace USDT probes: {}", msg
179-
);
180-
ProbeRegistration::Failed(msg)
181-
}
165+
#[cfg(feature = "usdt-probes")]
166+
let probe_registration = match usdt::register_probes() {
167+
Ok(_) => {
168+
debug!(
169+
self.app_state.log,
170+
"successfully registered DTrace USDT probes"
171+
);
172+
ProbeRegistration::Succeeded
182173
}
183-
} else {
174+
Err(e) => {
175+
let msg = e.to_string();
176+
error!(
177+
self.app_state.log,
178+
"failed to register DTrace USDT probes: {}", msg
179+
);
180+
ProbeRegistration::Failed(msg)
181+
}
182+
};
183+
#[cfg(not(feature = "usdt-probes"))]
184+
let probe_registration = {
184185
debug!(
185186
self.app_state.log,
186187
"DTrace USDT probes compiled out, not registering"

0 commit comments

Comments
 (0)