mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-09 03:38:00 +00:00
The telemetry should not be initialized if no telemetry has been provided (#6666)
* Initial commit
Forked at: e10598af1f
Parent branch: origin/master
* Fix: do not initialize telemetry if telemetry is not set
* Update client/telemetry/src/lib.rs
Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
* Update client/telemetry/src/lib.rs
* Update client/telemetry/src/lib.rs
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
This commit is contained in:
@@ -1012,7 +1012,12 @@ ServiceBuilder<
|
||||
let telemetry_connection_sinks: Arc<Mutex<Vec<TracingUnboundedSender<()>>>> = Default::default();
|
||||
|
||||
// Telemetry
|
||||
let telemetry = config.telemetry_endpoints.clone().map(|endpoints| {
|
||||
let telemetry = config.telemetry_endpoints.clone().and_then(|endpoints| {
|
||||
if endpoints.is_empty() {
|
||||
// we don't want the telemetry to be initialized if telemetry_endpoints == Some([])
|
||||
return None;
|
||||
}
|
||||
|
||||
let genesis_hash = match client.block_hash(Zero::zero()) {
|
||||
Ok(Some(hash)) => hash,
|
||||
_ => Default::default(),
|
||||
@@ -1031,7 +1036,7 @@ ServiceBuilder<
|
||||
future,
|
||||
);
|
||||
|
||||
telemetry
|
||||
Some(telemetry)
|
||||
});
|
||||
|
||||
// Instrumentation
|
||||
|
||||
@@ -123,6 +123,13 @@ impl TelemetryEndpoints {
|
||||
}
|
||||
}
|
||||
|
||||
impl TelemetryEndpoints {
|
||||
/// Return `true` if there are no telemetry endpoints, `false` otherwise.
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.0.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
/// Parses a WebSocket URL into a libp2p `Multiaddr`.
|
||||
fn url_to_multiaddr(url: &str) -> Result<Multiaddr, libp2p::multiaddr::Error> {
|
||||
// First, assume that we have a `Multiaddr`.
|
||||
|
||||
Reference in New Issue
Block a user