From b4ca959ca5cda90f071fc9682f81619353954e6d Mon Sep 17 00:00:00 2001 From: Adam Leventhal Date: Thu, 19 May 2022 20:56:13 -0700 Subject: [PATCH] make usdt an optional dependency (#354) --- dropshot/Cargo.toml | 1 + dropshot/src/lib.rs | 1 + dropshot/src/server.rs | 37 +++++++++++++++++++------------------ 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/dropshot/Cargo.toml b/dropshot/Cargo.toml index 8431aded1..3b51d6174 100644 --- a/dropshot/Cargo.toml +++ b/dropshot/Cargo.toml @@ -60,6 +60,7 @@ features = [ "full" ] [dependencies.usdt] version = "0.3.2" +optional = true default-features = false [dependencies.uuid] diff --git a/dropshot/src/lib.rs b/dropshot/src/lib.rs index 22364f2d1..9a7bb1451 100644 --- a/dropshot/src/lib.rs +++ b/dropshot/src/lib.rs @@ -578,6 +578,7 @@ pub(crate) struct ResponseInfo { message: String, } +#[cfg(feature = "usdt-probes")] #[usdt::provider(provider = "dropshot")] mod probes { use crate::{RequestInfo, ResponseInfo}; diff --git a/dropshot/src/server.rs b/dropshot/src/server.rs index 4db143ed0..99a4a046a 100644 --- a/dropshot/src/server.rs +++ b/dropshot/src/server.rs @@ -162,25 +162,26 @@ impl HttpServerStarter { }; 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"