Files
pezkuwi-subxt/substrate/client/telemetry
Igor Matuszewski 028f3d2674 Merge 2.0.1 backport branch into mainline master (#7842)
* Backport paritytech/substrate#7381

* Bring back genesis storage build in aura/timestamp

To not change spec version, see
https://github.com/paritytech/substrate/pull/7686#discussion_r540032743

* Backport paritytech/substrate#7238

* Backport paritytech/substrate#7395

* Bump impl_version

* Fix UI tests and bump trybuild dep

See https://github.com/rust-lang/rust/pull/73996

Backports:
https://github.com/paritytech/substrate/pull/7764
https://github.com/paritytech/substrate/pull/7656

* Partially backport paritytech/substrate#7838

* Release frame-support with a dep compilation fix

* Bump patch level for remaining crates

This is done because at the time of writing cargo-unleash does not fully
support partial workspace publishing and mixes both local and crates.io
versions of the packages, leading to errors in the release check workflow.

* Backport paritytech/substrate#7854

...to fix compilation error when using futures-* v0.3.9.

* Adding Changelog  entry for patch release

Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Benjamin Kampmann <ben@parity.io>
2021-01-11 11:24:29 +01:00
..
2021-01-04 09:03:13 +00:00
2020-08-20 17:04:42 +02:00

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 [TelemetryEvent]s.

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",
)

License: GPL-3.0-or-later WITH Classpath-exception-2.0