Repository: paritytech/substrate
File: client/network/src/service.rs (Rust)

Code before:
				"Number of internal active channels that broadcast network events",
			)?, registry)?,
			opened_notification_streams: register(GaugeVec::new(
				Opts::new(
					"sub_libp2p_opened_notification_streams",
					"Number of open notification substreams"
				),
				&["protocol"]
			)?, registry)?,
			peers_count: register(Gauge::new(
				"sub_libp2p_peers_count", "Number of network gossip peers",
			)?, registry)?,
			peerset_num_discovered: register(Gauge::new(
				"sub_libp2p_peerset_num_discovered", "Number of nodes stored in the peerset manager",
			)?, registry)?,
			peerset_num_requested: register(Gauge::new(
				"sub_libp2p_peerset_num_requested", "Number of nodes that the peerset manager wants us to be connected to",
			)?, registry)?,
			pending_connections: register(Gauge::new(
				"sub_libp2p_pending_connections",
				"Number of connections in the process of being established",
			)?, registry)?,
			pending_connections_errors_total: register(CounterVec::new(
				Opts::new(
					"sub_libp2p_pending_connections_errors_total",
					"Total number of failures to connection to a node"
				),
				&["reason"]
			)?, registry)?,
			random_kademalia_queries_total: register(Counter::new(
				"sub_libp2p_random_kademalia_queries_total", "Number of random Kademlia queries started",
			)?, registry)?,
		})
	}

	fn update_with_network_event(&self, event: &Event) {
		match event {
			Event::NotificationStreamOpened { engine_id, .. } => {
				self.opened_notification_streams.with_label_values(&[&engine_id_to_string(&engine_id)]).inc();
			},
			Event::NotificationStreamClosed { engine_id, .. } => {
				self.opened_notification_streams.with_label_values(&[&engine_id_to_string(&engine_id)]).dec();
			},
			Event::NotificationsReceived { messages, .. } => {
				for (engine_id, message) in messages {
					self.notifications_sizes
						.with_label_values(&["in", &engine_id_to_string(&engine_id)])
						.observe(message.len() as f64);
				}
			},
			_ => {}

Review comment (bug):
```suggestion
					"Total number of node connection failures"
```

Just a suggestion.

Code after:
				"Number of internal active channels that broadcast network events",
			)?, registry)?,
			opened_notification_streams: register(GaugeVec::new(
				Opts::new(
					"sub_libp2p_opened_notification_streams",
					"Number of open notification substreams"
				),
				&["protocol"]
			)?, registry)?,
			peers_count: register(Gauge::new(
				"sub_libp2p_peers_count", "Number of network gossip peers",
			)?, registry)?,
			peerset_num_discovered: register(Gauge::new(
				"sub_libp2p_peerset_num_discovered", "Number of nodes stored in the peerset manager",
			)?, registry)?,
			peerset_num_requested: register(Gauge::new(
				"sub_libp2p_peerset_num_requested", "Number of nodes that the peerset manager wants us to be connected to",
			)?, registry)?,
			pending_connections: register(Gauge::new(
				"sub_libp2p_pending_connections",
				"Number of connections in the process of being established",
			)?, registry)?,
			pending_connections_errors_total: register(CounterVec::new(
				Opts::new(
					"sub_libp2p_pending_connections_errors_total",
					"Total number of node connection failures"
				),
				&["reason"]
			)?, registry)?,
			random_kademalia_queries_total: register(Counter::new(
				"sub_libp2p_random_kademalia_queries_total", "Number of random Kademlia queries started",
			)?, registry)?,
		})
	}

	fn update_with_network_event(&self, event: &Event) {
		match event {
			Event::NotificationStreamOpened { engine_id, .. } => {
				self.opened_notification_streams.with_label_values(&[&engine_id_to_string(&engine_id)]).inc();
			},
			Event::NotificationStreamClosed { engine_id, .. } => {
				self.opened_notification_streams.with_label_values(&[&engine_id_to_string(&engine_id)]).dec();
			},
			Event::NotificationsReceived { messages, .. } => {
				for (engine_id, message) in messages {
					self.notifications_sizes
						.with_label_values(&["in", &engine_id_to_string(&engine_id)])
						.observe(message.len() as f64);
				}
			},
			_ => {}