observability: tracing gum, automatically cross ref traceID (#5079)

* add some gum

* bump expander

* gum

* fix all remaining issues

* last fixup

* Update node/gum/proc-macro/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* change

* netowrk

* fixins

* chore

* allow optional fmt str + args, prep for expr as kv field

* tracing -> gum rename fallout

* restrict further

* allow multiple levels of field accesses

* another round of docs and a slip of the pen

* update ADR

* fixup lock fiel

* use target: instead of target=

* minors

* fix

* chore

* Update node/gum/README.md

Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com>

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com>
This commit is contained in:
Bernhard Schuster
2022-03-15 12:05:16 +01:00
committed by GitHub
parent fa359fd1f7
commit d631f1dea8
130 changed files with 1708 additions and 808 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ polkadot-node-subsystem-types = { path = "../subsystem-types" }
polkadot-node-metrics = { path = "../metrics" }
polkadot-primitives = { path = "../../primitives" }
polkadot-overseer-gen = { path = "./overseer-gen" }
tracing = "0.1.32"
gum = { package = "tracing-gum", path = "../gum" }
lru = "0.7"
parity-util-mem = { version = "0.11.0", default-features = false }
@@ -59,13 +59,13 @@ impl Subsystem1 {
match ctx.try_recv().await {
Ok(Some(msg)) => {
if let FromOverseer::Communication { msg } = msg {
tracing::info!("msg {:?}", msg);
gum::info!("msg {:?}", msg);
}
continue 'louy
},
Ok(None) => (),
Err(_) => {
tracing::info!("exiting");
gum::info!("exiting");
break 'louy
},
}
@@ -121,7 +121,7 @@ impl Subsystem2 {
"subsystem-2-job",
Box::pin(async {
loop {
tracing::info!("Job tick");
gum::info!("Job tick");
Delay::new(Duration::from_secs(1)).await;
}
}),
@@ -131,14 +131,14 @@ impl Subsystem2 {
loop {
match ctx.try_recv().await {
Ok(Some(msg)) => {
tracing::info!("Subsystem2 received message {:?}", msg);
gum::info!("Subsystem2 received message {:?}", msg);
continue
},
Ok(None) => {
pending!();
},
Err(_) => {
tracing::info!("exiting");
gum::info!("exiting");
return
},
}
@@ -189,7 +189,7 @@ fn main() {
select! {
_ = overseer_fut => break,
_ = timer_stream.next() => {
tracing::info!("tick");
gum::info!("tick");
}
complete => break,
}
@@ -6,7 +6,7 @@ edition = "2021"
description = "Generate an overseer including builder pattern and message wrapper from a single struct."
[dependencies]
tracing = "0.1"
gum = { package = "tracing-gum", path = "../../gum" }
futures = "0.3"
async-trait = "0.1"
thiserror = "1"
@@ -624,9 +624,9 @@ pub(crate) fn impl_task_kind(info: &OverseerInfo) -> proc_macro2::TokenStream {
let fut = Box::pin(async move {
if let Err(e) = future.await {
#support_crate ::tracing::error!(subsystem=name, err = ?e, "subsystem exited with error");
#support_crate ::gum::error!(subsystem=name, err = ?e, "subsystem exited with error");
} else {
#support_crate ::tracing::debug!(subsystem=name, "subsystem exited without an error");
#support_crate ::gum::debug!(subsystem=name, "subsystem exited without an error");
}
let _ = tx.send(());
});
@@ -635,7 +635,7 @@ pub(crate) fn impl_task_kind(info: &OverseerInfo) -> proc_macro2::TokenStream {
futures.push(Box::pin(
rx.map(|e| {
tracing::warn!(err = ?e, "dropping error");
gum::warn!(err = ?e, "dropping error");
Ok(())
})
));
@@ -82,7 +82,7 @@ pub(crate) fn impl_channels_out_struct(info: &OverseerInfo) -> Result<proc_macro
};
if let Err(subsystem_name) = res {
#support_crate ::tracing::debug!(
#support_crate ::gum::debug!(
target: LOG_TARGET,
"Failed to send (bounded) a message to {} subsystem",
subsystem_name
@@ -114,7 +114,7 @@ pub(crate) fn impl_channels_out_struct(info: &OverseerInfo) -> Result<proc_macro
};
if let Err(subsystem_name) = res {
#support_crate ::tracing::debug!(
#support_crate ::gum::debug!(
target: LOG_TARGET,
"Failed to send_unbounded a message to {} subsystem",
subsystem_name
@@ -212,7 +212,7 @@ pub(crate) fn impl_overseen_subsystem(info: &OverseerInfo) -> proc_macro2::Token
}).timeout(MESSAGE_TIMEOUT).await
{
None => {
#support_crate ::tracing::error!(
#support_crate ::gum::error!(
target: LOG_TARGET,
%origin,
"Subsystem {} appears unresponsive.",
@@ -62,12 +62,12 @@
pub use polkadot_overseer_gen_proc_macro::overlord;
#[doc(hidden)]
pub use gum;
#[doc(hidden)]
pub use metered;
#[doc(hidden)]
pub use polkadot_node_primitives::SpawnNamed;
#[doc(hidden)]
pub use tracing;
#[doc(hidden)]
pub use async_trait::async_trait;
+1 -1
View File
@@ -43,7 +43,7 @@ where
Err(_) => return Ok(()),
Ok(FromOverseer::Signal(OverseerSignal::Conclude)) => return Ok(()),
Ok(overseer_msg) => {
tracing::debug!(
gum::debug!(
target: "dummy-subsystem",
"Discarding a message sent from overseer {:?}",
overseer_msg
+6 -9
View File
@@ -199,7 +199,7 @@ impl Handle {
/// Most basic operation, to stop a server.
async fn send_and_log_error(&mut self, event: Event) {
if self.0.send(event).await.is_err() {
tracing::info!(target: LOG_TARGET, "Failed to send an event to Overseer");
gum::info!(target: LOG_TARGET, "Failed to send an event to Overseer");
}
}
}
@@ -529,21 +529,18 @@ where
Ok(memory_stats) =>
Box::new(move |metrics: &OverseerMetrics| match memory_stats.snapshot() {
Ok(memory_stats_snapshot) => {
tracing::trace!(
gum::trace!(
target: LOG_TARGET,
"memory_stats: {:?}",
&memory_stats_snapshot
);
metrics.memory_stats_snapshot(memory_stats_snapshot);
},
Err(e) => tracing::debug!(
target: LOG_TARGET,
"Failed to obtain memory stats: {:?}",
e
),
Err(e) =>
gum::debug!(target: LOG_TARGET, "Failed to obtain memory stats: {:?}", e),
}),
Err(_) => {
tracing::debug!(
gum::debug!(
target: LOG_TARGET,
"Memory allocation tracking is not supported by the allocator.",
);
@@ -634,7 +631,7 @@ where
}
},
res = self.running_subsystems.select_next_some() => {
tracing::error!(
gum::error!(
target: LOG_TARGET,
subsystem = ?res,
"subsystem finished unexpectedly",