mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 01:01:04 +00:00
Rework telemetry to replace the use of tracing with an object we pass around (#8143)
polkadot companion: paritytech/polkadot#2535
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
//!
|
||||
//! See `sp-tracing` for examples on how to use tracing.
|
||||
//!
|
||||
//! Currently we provide `Log` (default), `Telemetry` variants for `Receiver`
|
||||
//! Currently we only provide `Log` (default).
|
||||
|
||||
#![warn(missing_docs)]
|
||||
|
||||
@@ -46,7 +46,6 @@ use tracing_subscriber::{
|
||||
CurrentSpan,
|
||||
layer::{Layer, Context},
|
||||
};
|
||||
use sc_telemetry::{telemetry, SUBSTRATE_INFO};
|
||||
use sp_tracing::{WASM_NAME_KEY, WASM_TARGET_KEY, WASM_TRACE_IDENTIFIER};
|
||||
|
||||
#[doc(hidden)]
|
||||
@@ -67,8 +66,6 @@ pub struct ProfilingLayer {
|
||||
pub enum TracingReceiver {
|
||||
/// Output to logger
|
||||
Log,
|
||||
/// Output to telemetry
|
||||
Telemetry,
|
||||
}
|
||||
|
||||
impl Default for TracingReceiver {
|
||||
@@ -214,10 +211,6 @@ impl ProfilingLayer {
|
||||
pub fn new(receiver: TracingReceiver, targets: &str) -> Self {
|
||||
match receiver {
|
||||
TracingReceiver::Log => Self::new_with_handler(Box::new(LogTraceHandler), targets),
|
||||
TracingReceiver::Telemetry => Self::new_with_handler(
|
||||
Box::new(TelemetryTraceHandler),
|
||||
targets,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,33 +385,6 @@ impl TraceHandler for LogTraceHandler {
|
||||
}
|
||||
}
|
||||
|
||||
/// TraceHandler for sending span data to telemetry,
|
||||
/// Please see telemetry documentation for details on how to specify endpoints and
|
||||
/// set the required telemetry level to activate tracing messages
|
||||
pub struct TelemetryTraceHandler;
|
||||
|
||||
impl TraceHandler for TelemetryTraceHandler {
|
||||
fn handle_span(&self, span_datum: SpanDatum) {
|
||||
telemetry!(SUBSTRATE_INFO; "tracing.profiling";
|
||||
"name" => span_datum.name,
|
||||
"target" => span_datum.target,
|
||||
"time" => span_datum.overall_time.as_nanos(),
|
||||
"id" => span_datum.id.into_u64(),
|
||||
"parent_id" => span_datum.parent_id.as_ref().map(|i| i.into_u64()),
|
||||
"values" => span_datum.values
|
||||
);
|
||||
}
|
||||
|
||||
fn handle_event(&self, event: TraceEvent) {
|
||||
telemetry!(SUBSTRATE_INFO; "tracing.event";
|
||||
"name" => event.name,
|
||||
"target" => event.target,
|
||||
"parent_id" => event.parent_id.as_ref().map(|i| i.into_u64()),
|
||||
"values" => event.values
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user