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

Code before:
	is_major_syncing: Gauge<U64>,
	issued_light_requests: Counter<U64>,
	kbuckets_num_nodes: Gauge<U64>,
	listeners_local_addresses: Gauge<U64>,
	listeners_errors_total: Counter<U64>,
	network_per_sec_bytes: GaugeVec<U64>,
	notifications_queues_size: HistogramVec,
	notifications_sizes: HistogramVec,
	num_event_stream_channels: Gauge<U64>,
	opened_notification_streams: GaugeVec<U64>,
	peers_count: Gauge<U64>,
	peerset_num_discovered: Gauge<U64>,
	peerset_num_requested: Gauge<U64>,
	pending_connections: Gauge<U64>,
	pending_connections_errors_total: CounterVec<U64>,
	random_kademalia_queries_total: Counter<U64>,
}

impl Metrics {
	fn register(registry: &Registry) -> Result<Self, PrometheusError> {
		Ok(Self {
			// This list is ordered alphabetically
			connections: register(GaugeVec::new(
				Opts::new(
					"sub_libp2p_connections",
					"Number of libp2p connections"
				),
				&["direction"]
			)?, registry)?,
			connections_closed_total: register(CounterVec::new(
				Opts::new(
					"sub_libp2p_connections_closed_total",
					"Total number of connections closed, by reason"
				),
				&["reason"]
			)?, registry)?,
			import_queue_blocks_submitted: register(Counter::new(
				"import_queue_blocks_submitted",
				"Number of blocks submitted to the import queue.",
			)?, registry)?,
			import_queue_finality_proofs_submitted: register(Counter::new(
				"import_queue_finality_proofs_submitted",
				"Number of finality proofs submitted to the import queue.",
			)?, registry)?,
			import_queue_justifications_submitted: register(Counter::new(
				"import_queue_justifications_submitted",
				"Number of justifications submitted to the import queue.",
			)?, registry)?,
			incoming_connections_errors_total: register(Counter::new(
				"sub_libp2p_incoming_connections_errors_total",
				"Total number of incoming connections that have failed during the initial handshake"

Review comment (suggestion):
To make sure not to confuse this with a monotonic increasing counter, how about the following addition?
```suggestion
					"Number of active libp2p connections"
```

Code after:
	is_major_syncing: Gauge<U64>,
	issued_light_requests: Counter<U64>,
	kbuckets_num_nodes: Gauge<U64>,
	listeners_local_addresses: Gauge<U64>,
	listeners_errors_total: Counter<U64>,
	network_per_sec_bytes: GaugeVec<U64>,
	notifications_queues_size: HistogramVec,
	notifications_sizes: HistogramVec,
	num_event_stream_channels: Gauge<U64>,
	opened_notification_streams: GaugeVec<U64>,
	peers_count: Gauge<U64>,
	peerset_num_discovered: Gauge<U64>,
	peerset_num_requested: Gauge<U64>,
	pending_connections: Gauge<U64>,
	pending_connections_errors_total: CounterVec<U64>,
	random_kademalia_queries_total: Counter<U64>,
}

impl Metrics {
	fn register(registry: &Registry) -> Result<Self, PrometheusError> {
		Ok(Self {
			// This list is ordered alphabetically
			connections: register(GaugeVec::new(
				Opts::new(
					"sub_libp2p_connections",
					"Number of active libp2p connections"
				),
				&["direction"]
			)?, registry)?,
			connections_closed_total: register(CounterVec::new(
				Opts::new(
					"sub_libp2p_connections_closed_total",
					"Total number of connections closed, by reason"
				),
				&["reason"]
			)?, registry)?,
			import_queue_blocks_submitted: register(Counter::new(
				"import_queue_blocks_submitted",
				"Number of blocks submitted to the import queue.",
			)?, registry)?,
			import_queue_finality_proofs_submitted: register(Counter::new(
				"import_queue_finality_proofs_submitted",
				"Number of finality proofs submitted to the import queue.",
			)?, registry)?,
			import_queue_justifications_submitted: register(Counter::new(
				"import_queue_justifications_submitted",
				"Number of justifications submitted to the import queue.",
			)?, registry)?,
			incoming_connections_errors_total: register(Counter::new(
				"sub_libp2p_incoming_connections_handshake_errors_total",
				"Total number of incoming connections that have failed during the initial handshake"