mirror of
https://github.com/logos-co/Overwatch.git
synced 2025-02-26 13:15:29 +00:00
Feature gate instrument macro.
This commit is contained in:
parent
848e3635d7
commit
78dfd8999d
@ -7,4 +7,4 @@ members = [
|
|||||||
|
|
||||||
[profile.release-opt]
|
[profile.release-opt]
|
||||||
inherits = "release"
|
inherits = "release"
|
||||||
lto = true
|
lto = true
|
||||||
|
@ -21,6 +21,7 @@ exclude = [
|
|||||||
[features]
|
[features]
|
||||||
default = ["derive"]
|
default = ["derive"]
|
||||||
derive = ["dep:overwatch-derive"]
|
derive = ["dep:overwatch-derive"]
|
||||||
|
instrumentation = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
overwatch-derive = { path = "../overwatch-derive", optional = true }
|
overwatch-derive = { path = "../overwatch-derive", optional = true }
|
||||||
|
@ -62,14 +62,13 @@ impl OverwatchHandle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Send an overwatch command to the overwatch runner
|
/// 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) {
|
pub async fn send(&self, command: OverwatchCommand) {
|
||||||
if let Err(e) = self.sender.send(command).await {
|
if let Err(e) = self.sender.send(command).await {
|
||||||
error!(error=?e, "Error sending overwatch command");
|
error!(error=?e, "Error sending overwatch command");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[cfg_attr(feature = "instrumentation", instrument(skip(self)))]
|
||||||
#[instrument(skip(self))]
|
|
||||||
pub async fn update_settings<S: Services>(&self, settings: S::Settings)
|
pub async fn update_settings<S: Services>(&self, settings: S::Settings)
|
||||||
where
|
where
|
||||||
S::Settings: Send,
|
S::Settings: Send,
|
||||||
|
@ -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>) {
|
async fn run_(self, mut receiver: Receiver<OverwatchCommand>) {
|
||||||
let Self {
|
let Self {
|
||||||
mut services,
|
mut services,
|
||||||
|
@ -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> {
|
pub async fn connect(self) -> Result<OutboundRelay<S::Message>, RelayError> {
|
||||||
let (reply, receiver) = oneshot::channel();
|
let (reply, receiver) = oneshot::channel();
|
||||||
self.request_relay(reply).await;
|
self.request_relay(reply).await;
|
||||||
@ -179,7 +179,7 @@ impl<S: ServiceData> Relay<S> {
|
|||||||
self.overwatch_handle.send(relay_command).await;
|
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(
|
async fn handle_relay_response(
|
||||||
&self,
|
&self,
|
||||||
receiver: oneshot::Receiver<RelayResult>,
|
receiver: oneshot::Receiver<RelayResult>,
|
||||||
|
@ -41,7 +41,7 @@ impl<S> SettingsUpdater<S> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Send a new settings update notification to the watcher end
|
/// 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) {
|
pub fn update(&self, settings: S) {
|
||||||
self.sender.send(settings).unwrap_or_else(|_e| {
|
self.sender.send(settings).unwrap_or_else(|_e| {
|
||||||
error!("Error sending settings update for service");
|
error!("Error sending settings update for service");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user