2019-05-28 07:30:09 +00:00
|
|
|
pub use prometheus::Error;
|
2019-05-29 05:45:09 +00:00
|
|
|
use prometheus::{Histogram, HistogramOpts, IntCounter, Opts, Registry};
|
2019-05-28 07:30:09 +00:00
|
|
|
|
|
|
|
pub struct Metrics {
|
2019-05-29 05:45:09 +00:00
|
|
|
pub block_processing_requests: IntCounter,
|
|
|
|
pub block_processing_successes: IntCounter,
|
2019-05-29 07:52:43 +00:00
|
|
|
pub block_processing_times: Histogram,
|
2019-05-28 07:30:09 +00:00
|
|
|
pub block_production_requests: IntCounter,
|
|
|
|
pub block_production_successes: IntCounter,
|
2019-05-29 07:52:43 +00:00
|
|
|
pub block_production_times: Histogram,
|
2019-05-28 07:30:09 +00:00
|
|
|
pub attestation_production_requests: IntCounter,
|
|
|
|
pub attestation_production_successes: IntCounter,
|
2019-05-29 07:52:43 +00:00
|
|
|
pub attestation_production_times: Histogram,
|
|
|
|
pub attestation_processing_requests: IntCounter,
|
|
|
|
pub attestation_processing_successes: IntCounter,
|
|
|
|
pub attestation_processing_times: Histogram,
|
|
|
|
pub fork_choice_requests: IntCounter,
|
|
|
|
pub fork_choice_changed_head: IntCounter,
|
|
|
|
pub fork_choice_reorg_count: IntCounter,
|
|
|
|
pub fork_choice_times: Histogram,
|
2019-06-01 05:29:13 +00:00
|
|
|
pub operations_per_block_attestation: Histogram,
|
2019-05-28 07:30:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Metrics {
|
|
|
|
pub fn new() -> Result<Self, Error> {
|
|
|
|
Ok(Self {
|
2019-05-29 05:45:09 +00:00
|
|
|
block_processing_requests: {
|
2019-05-29 08:09:51 +00:00
|
|
|
let opts = Opts::new("block_processing_requests", "total_blocks_processed");
|
2019-05-28 07:30:09 +00:00
|
|
|
IntCounter::with_opts(opts)?
|
|
|
|
},
|
2019-05-29 05:45:09 +00:00
|
|
|
block_processing_successes: {
|
2019-05-29 08:09:51 +00:00
|
|
|
let opts = Opts::new("block_processing_successes", "total_valid_blocks_processed");
|
2019-05-28 07:30:09 +00:00
|
|
|
IntCounter::with_opts(opts)?
|
|
|
|
},
|
2019-05-29 07:52:43 +00:00
|
|
|
block_processing_times: {
|
|
|
|
let opts = HistogramOpts::new("block_processing_times", "block_processing_time");
|
2019-05-29 05:45:09 +00:00
|
|
|
Histogram::with_opts(opts)?
|
|
|
|
},
|
2019-05-28 07:30:09 +00:00
|
|
|
block_production_requests: {
|
|
|
|
let opts = Opts::new("block_production_requests", "attempts_to_produce_new_block");
|
|
|
|
IntCounter::with_opts(opts)?
|
|
|
|
},
|
|
|
|
block_production_successes: {
|
|
|
|
let opts = Opts::new("block_production_successes", "blocks_successfully_produced");
|
|
|
|
IntCounter::with_opts(opts)?
|
|
|
|
},
|
2019-05-29 07:52:43 +00:00
|
|
|
block_production_times: {
|
|
|
|
let opts = HistogramOpts::new("block_production_times", "block_production_time");
|
2019-05-29 05:45:09 +00:00
|
|
|
Histogram::with_opts(opts)?
|
|
|
|
},
|
2019-05-28 07:30:09 +00:00
|
|
|
attestation_production_requests: {
|
|
|
|
let opts = Opts::new(
|
|
|
|
"attestation_production_requests",
|
|
|
|
"total_attestation_production_requests",
|
|
|
|
);
|
|
|
|
IntCounter::with_opts(opts)?
|
|
|
|
},
|
|
|
|
attestation_production_successes: {
|
|
|
|
let opts = Opts::new(
|
|
|
|
"attestation_production_successes",
|
|
|
|
"total_attestation_production_successes",
|
|
|
|
);
|
|
|
|
IntCounter::with_opts(opts)?
|
|
|
|
},
|
2019-05-29 07:52:43 +00:00
|
|
|
attestation_production_times: {
|
2019-05-29 05:45:09 +00:00
|
|
|
let opts = HistogramOpts::new(
|
2019-05-29 07:52:43 +00:00
|
|
|
"attestation_production_times",
|
2019-05-29 05:45:09 +00:00
|
|
|
"attestation_production_time",
|
|
|
|
);
|
|
|
|
Histogram::with_opts(opts)?
|
|
|
|
},
|
2019-05-29 07:52:43 +00:00
|
|
|
attestation_processing_requests: {
|
|
|
|
let opts = Opts::new(
|
|
|
|
"attestation_processing_requests",
|
|
|
|
"total_attestation_processing_requests",
|
|
|
|
);
|
|
|
|
IntCounter::with_opts(opts)?
|
|
|
|
},
|
|
|
|
attestation_processing_successes: {
|
|
|
|
let opts = Opts::new(
|
|
|
|
"attestation_processing_successes",
|
|
|
|
"total_attestation_processing_successes",
|
|
|
|
);
|
|
|
|
IntCounter::with_opts(opts)?
|
|
|
|
},
|
|
|
|
attestation_processing_times: {
|
|
|
|
let opts = HistogramOpts::new(
|
|
|
|
"attestation_processing_times",
|
|
|
|
"attestation_processing_time",
|
|
|
|
);
|
|
|
|
Histogram::with_opts(opts)?
|
|
|
|
},
|
|
|
|
fork_choice_requests: {
|
|
|
|
let opts = Opts::new("fork_choice_requests", "total_times_fork_choice_called");
|
|
|
|
IntCounter::with_opts(opts)?
|
|
|
|
},
|
|
|
|
fork_choice_changed_head: {
|
|
|
|
let opts = Opts::new(
|
|
|
|
"fork_choice_changed_head",
|
|
|
|
"total_times_fork_choice_chose_a_new_head",
|
|
|
|
);
|
|
|
|
IntCounter::with_opts(opts)?
|
|
|
|
},
|
|
|
|
fork_choice_reorg_count: {
|
2019-05-29 08:09:51 +00:00
|
|
|
let opts = Opts::new("fork_choice_reorg_count", "number_of_reorgs");
|
2019-05-29 07:52:43 +00:00
|
|
|
IntCounter::with_opts(opts)?
|
|
|
|
},
|
|
|
|
fork_choice_times: {
|
|
|
|
let opts = HistogramOpts::new("fork_choice_time", "total_time_to_run_fork_choice");
|
|
|
|
Histogram::with_opts(opts)?
|
|
|
|
},
|
2019-06-01 05:29:13 +00:00
|
|
|
operations_per_block_attestation: {
|
|
|
|
let opts = HistogramOpts::new(
|
|
|
|
"operations_per_block_attestation",
|
|
|
|
"count_of_attestations_per_block",
|
|
|
|
);
|
|
|
|
Histogram::with_opts(opts)?
|
|
|
|
},
|
2019-05-28 07:30:09 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn register(&self, registry: &Registry) -> Result<(), Error> {
|
2019-05-29 05:45:09 +00:00
|
|
|
registry.register(Box::new(self.block_processing_requests.clone()))?;
|
|
|
|
registry.register(Box::new(self.block_processing_successes.clone()))?;
|
2019-05-29 07:52:43 +00:00
|
|
|
registry.register(Box::new(self.block_processing_times.clone()))?;
|
2019-05-28 07:30:09 +00:00
|
|
|
registry.register(Box::new(self.block_production_requests.clone()))?;
|
|
|
|
registry.register(Box::new(self.block_production_successes.clone()))?;
|
2019-05-29 07:52:43 +00:00
|
|
|
registry.register(Box::new(self.block_production_times.clone()))?;
|
2019-05-28 07:30:09 +00:00
|
|
|
registry.register(Box::new(self.attestation_production_requests.clone()))?;
|
|
|
|
registry.register(Box::new(self.attestation_production_successes.clone()))?;
|
2019-05-29 07:52:43 +00:00
|
|
|
registry.register(Box::new(self.attestation_production_times.clone()))?;
|
|
|
|
registry.register(Box::new(self.attestation_processing_requests.clone()))?;
|
|
|
|
registry.register(Box::new(self.attestation_processing_successes.clone()))?;
|
|
|
|
registry.register(Box::new(self.attestation_processing_times.clone()))?;
|
|
|
|
registry.register(Box::new(self.fork_choice_requests.clone()))?;
|
|
|
|
registry.register(Box::new(self.fork_choice_changed_head.clone()))?;
|
|
|
|
registry.register(Box::new(self.fork_choice_reorg_count.clone()))?;
|
|
|
|
registry.register(Box::new(self.fork_choice_times.clone()))?;
|
2019-06-01 05:29:13 +00:00
|
|
|
registry.register(Box::new(self.operations_per_block_attestation.clone()))?;
|
2019-05-28 07:30:09 +00:00
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|