Files
pezkuwi-subxt/substrate/client/telemetry
Max Inden 0a2636d20c *: Update to libp2p v0.32.0 (#7696)
* *: Update to libp2p v0.32.0

* Cargo.lock: Update async-tls to 0.10.2

* client/network/request_response: Adjust to new request response events

* client/network/request_response.rs: Clean up silently failing responses

* client/network/discovery: Lazily instantiate mdns

* client/network/discovery: Exclude MdnsWrapper for target_os unknown

* client/network/discovery: Fix indentation

* client/network/request-response: Use LruCache to track pending resp time

* client/network/request_responses: Fix early connection closed error

* client/network/request-response: Replace debug_assert with debug

* client/network/request-response: Fix typo

* client/network/request-response: Don't emit event on send_response fail

* client/network/request-response: Revert waker.wake_by_ref()

* client/network/request-resp: Make duration in InboundRequest optional

* client/network/req-resp: Don't emit two events for busy builder

When a response builder is busy incoming requests are dropped.
Previously this was reported both via a `ResponseFailure::Busy` and a
`ReponseFailure::Network(InboundFailure::Omisssion)` event.

With this commit the former is removed, leaving only the latter in
place.
2020-12-09 21:58:22 +00:00
..
2020-10-30 15:43:28 +00:00
2020-12-09 21:58:22 +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