referrerpolicy=no-referrer-when-downgrade

sc_transaction_pool/single_state_txpool/
metrics.rs

1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
5
6// This program is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License
17// along with this program. If not, see <https://www.gnu.org/licenses/>.
18
19//! Transaction pool Prometheus metrics for single-state transaction pool.
20
21use crate::common::metrics::{GenericMetricsLink, MetricsRegistrant};
22use prometheus_endpoint::{register, Counter, PrometheusError, Registry, U64};
23
24pub type MetricsLink = GenericMetricsLink<Metrics>;
25
26/// Transaction pool Prometheus metrics.
27pub struct Metrics {
28	pub submitted_transactions: Counter<U64>,
29	pub validations_invalid: Counter<U64>,
30	pub block_transactions_pruned: Counter<U64>,
31	pub block_transactions_resubmitted: Counter<U64>,
32}
33
34impl MetricsRegistrant for Metrics {
35	fn register(registry: &Registry) -> Result<Box<Self>, PrometheusError> {
36		Ok(Box::from(Self {
37			submitted_transactions: register(
38				Counter::new(
39					"substrate_sub_txpool_submitted_transactions",
40					"Total number of transactions submitted",
41				)?,
42				registry,
43			)?,
44			validations_invalid: register(
45				Counter::new(
46					"substrate_sub_txpool_validations_invalid",
47					"Total number of transactions that were removed from the pool as invalid",
48				)?,
49				registry,
50			)?,
51			block_transactions_pruned: register(
52				Counter::new(
53					"substrate_sub_txpool_block_transactions_pruned",
54					"Total number of transactions that was requested to be pruned by block events",
55				)?,
56				registry,
57			)?,
58			block_transactions_resubmitted: register(
59				Counter::new(
60					"substrate_sub_txpool_block_transactions_resubmitted",
61					"Total number of transactions that was requested to be resubmitted by block events",
62				)?,
63				registry,
64			)?,
65		}))
66	}
67}