Feature gate instrument macro.

This commit is contained in:
Alejandro Cabeza Romero 2024-12-19 16:14:18 +01:00
parent 848e3635d7
commit 78dfd8999d
No known key found for this signature in database
GPG Key ID: DA3D14AE478030FD
6 changed files with 8 additions and 8 deletions

View File

@ -7,4 +7,4 @@ members = [
[profile.release-opt]
inherits = "release"
lto = true
lto = true

View File

@ -21,6 +21,7 @@ exclude = [
[features]
default = ["derive"]
derive = ["dep:overwatch-derive"]
instrumentation = []
[dependencies]
overwatch-derive = { path = "../overwatch-derive", optional = true }

View File

@ -62,14 +62,13 @@ impl OverwatchHandle {
}
/// Send an overwatch command to the overwatch runner
#[instrument(name = "overwatch-command-send", skip(self))]
#[cfg_attr(feature = "instrumentation", instrument(name = "overwatch-command-send", skip(self)))]
pub async fn send(&self, command: OverwatchCommand) {
if let Err(e) = self.sender.send(command).await {
error!(error=?e, "Error sending overwatch command");
}
}
#[instrument(skip(self))]
#[cfg_attr(feature = "instrumentation", instrument(skip(self)))]
pub async fn update_settings<S: Services>(&self, settings: S::Settings)
where
S::Settings: Send,

View File

@ -142,7 +142,7 @@ where
})
}
#[instrument(name = "overwatch-run", skip_all)]
#[cfg_attr(feature = "instrumentation", instrument(name = "overwatch-run", skip_all))]
async fn run_(self, mut receiver: Receiver<OverwatchCommand>) {
let Self {
mut services,

View File

@ -164,7 +164,7 @@ impl<S: ServiceData> Relay<S> {
}
}
#[instrument(skip(self), err(Debug))]
#[cfg_attr(feature = "instrumentation", instrument(skip(self), err(Debug)))]
pub async fn connect(self) -> Result<OutboundRelay<S::Message>, RelayError> {
let (reply, receiver) = oneshot::channel();
self.request_relay(reply).await;
@ -179,7 +179,7 @@ impl<S: ServiceData> Relay<S> {
self.overwatch_handle.send(relay_command).await;
}
#[instrument(skip_all, err(Debug))]
#[cfg_attr(feature = "instrumentation", instrument(skip_all, err(Debug)))]
async fn handle_relay_response(
&self,
receiver: oneshot::Receiver<RelayResult>,

View File

@ -41,7 +41,7 @@ impl<S> SettingsUpdater<S> {
}
/// Send a new settings update notification to the watcher end
#[instrument(skip_all)]
#[cfg_attr(feature = "instrumentation", instrument(skip_all))]
pub fn update(&self, settings: S) {
self.sender.send(settings).unwrap_or_else(|_e| {
error!("Error sending settings update for service");