[][src]Crate sc_telemetry

Telemetry utilities.

Calling init_telemetry registers a global slog logger using slog_scope::set_global_logger. After that, calling slog_scope::with_logger will return a logger that sends information to the telemetry endpoints. The telemetry! macro is a short-cut for calling slog_scope::with_logger followed with slog_log!.

Note that you are supposed to only ever use telemetry! and not slog_scope::with_logger at the moment. Substrate may eventually be reworked to get proper slog support, including sending information to the telemetry.

The Telemetry struct implements Stream and must be polled regularly (or sent to a background thread/task) in order for the telemetry to properly function. Dropping the object will also deregister the global logger and replace it with a logger that discards messages. The Stream generates TelemetryEvents.

Note: Cloning the Telemetry and polling from multiple clones has an unspecified behaviour.

Example

use futures::prelude::*;

let telemetry = sc_telemetry::init_telemetry(sc_telemetry::TelemetryConfig {
	endpoints: sc_telemetry::TelemetryEndpoints::new(vec![
		// The `0` is the maximum verbosity level of messages to send to this endpoint.
		("wss://example.com".into(), 0)
	]).expect("Invalid URL or multiaddr provided"),
	// Can be used to pass an external implementation of WebSockets.
	wasm_external_transport: None,
});

// The `telemetry` object implements `Stream` and must be processed.
std::thread::spawn(move || {
	futures::executor::block_on(telemetry.for_each(|_| future::ready(())));
});

// Sends a message on the telemetry.
sc_telemetry::telemetry!(sc_telemetry::SUBSTRATE_INFO; "test";
	"foo" => "bar",
)

Re-exports

pub use slog;

Macros

telemetry

Translates to slog_scope::info, but contains an additional verbosity parameter which the log record is tagged with. Additionally the verbosity parameter is added to the record as a key-value pair.

Structs

ExtTransport

Implementation of Transport whose implementation is handled by some FFI.

Telemetry

Telemetry object. Implements Future and must be polled regularly. Contains an Arc and can be cloned and pass around. Only one clone needs to be polled regularly and should be polled regularly. Dropping all the clones unregisters the telemetry.

TelemetryConfig

Configuration for telemetry.

TelemetryEndpoints

List of telemetry servers we want to talk to. Contains the URL of the server, and the maximum verbosity level.

Enums

TelemetryEvent

Event generated when polling the worker.

Constants

CONSENSUS_DEBUG
CONSENSUS_INFO
CONSENSUS_TRACE
CONSENSUS_WARN
SUBSTRATE_DEBUG

Log levels.

SUBSTRATE_INFO

Functions

init_telemetry

Initializes the telemetry. See the crate root documentation for more information.

with_logger

Access the Logger for the current logging scope