Feature gate instrument imports.

This commit is contained in:
Alejandro Cabeza Romero 2024-12-19 16:20:37 +01:00
parent 78dfd8999d
commit dd93596818
No known key found for this signature in database
GPG Key ID: DA3D14AE478030FD
4 changed files with 22 additions and 7 deletions

View File

@ -6,7 +6,9 @@ use crate::overwatch::Services;
use crate::services::ServiceData;
use tokio::runtime::Handle;
use tokio::sync::mpsc::Sender;
use tracing::{error, info, instrument};
use tracing::{error, info};
#[cfg(feature = "instrumentation")]
use tracing::instrument;
// internal
use crate::services::relay::Relay;
@ -62,7 +64,10 @@ impl OverwatchHandle {
}
/// Send an overwatch command to the overwatch runner
#[cfg_attr(feature = "instrumentation", 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");

View File

@ -15,7 +15,9 @@ use tokio::runtime::{Handle, Runtime};
use tokio::sync::mpsc::Receiver;
use tokio::sync::oneshot;
use tokio::task::JoinHandle;
use tracing::{error, info, instrument};
use tracing::{error, info};
#[cfg(feature = "instrumentation")]
use tracing::instrument;
// internal
use crate::overwatch::commands::{
@ -142,7 +144,10 @@ where
})
}
#[cfg_attr(feature = "instrumentation", 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

@ -10,7 +10,9 @@ use thiserror::Error;
use tokio::sync::mpsc::{channel, Receiver, Sender};
use tokio::sync::oneshot;
use tokio_util::sync::PollSender;
use tracing::{error, instrument};
use tracing::error;
#[cfg(feature = "instrumentation")]
use tracing::instrument;
// internal
use crate::overwatch::commands::{OverwatchCommand, RelayCommand, ReplyChannel};
use crate::overwatch::handle::OverwatchHandle;
@ -179,7 +181,8 @@ impl<S: ServiceData> Relay<S> {
self.overwatch_handle.send(relay_command).await;
}
#[cfg_attr(feature = "instrumentation", 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

@ -1,7 +1,9 @@
//std
//crates
use tokio::sync::watch::{channel, Receiver, Sender};
use tracing::{error, instrument};
use tracing::error;
#[cfg(feature = "instrumentation")]
use tracing::instrument;
//internal
/// Wrapper around [`tokio::sync::watch::Receiver`]