This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
metrics separation #5391
Merged
Merged
metrics separation #5391
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
05efd90
split metrics from collation generation
drahnr 9fcef75
move metrics to separate file out of backing
drahnr 68f4690
split bitfield signing metrics
drahnr b4883d7
split candidate validation metrics
drahnr 0410b99
split chain api metrics
drahnr 158b574
split metrics from runtime API
drahnr e9e23b7
util is not used in backed metrics mod
drahnr 2c40d63
fmt
drahnr e2aafce
missing types
drahnr 114c679
sure
drahnr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| // Copyright 2020 Parity Technologies (UK) Ltd. | ||
| // This file is part of Polkadot. | ||
|
|
||
| // Polkadot is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
|
|
||
| // Polkadot is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License for more details. | ||
|
|
||
| // You should have received a copy of the GNU General Public License | ||
| // along with Polkadot. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| use polkadot_node_subsystem_util::metrics::{self, prometheus}; | ||
|
|
||
| #[derive(Clone)] | ||
| pub(crate) struct MetricsInner { | ||
| pub(crate) collations_generated_total: prometheus::Counter<prometheus::U64>, | ||
| pub(crate) new_activations_overall: prometheus::Histogram, | ||
| pub(crate) new_activations_per_relay_parent: prometheus::Histogram, | ||
| pub(crate) new_activations_per_availability_core: prometheus::Histogram, | ||
| } | ||
|
|
||
| /// `CollationGenerationSubsystem` metrics. | ||
| #[derive(Default, Clone)] | ||
| pub struct Metrics(pub(crate) Option<MetricsInner>); | ||
|
|
||
| impl Metrics { | ||
| pub fn on_collation_generated(&self) { | ||
| if let Some(metrics) = &self.0 { | ||
| metrics.collations_generated_total.inc(); | ||
| } | ||
| } | ||
|
|
||
| /// Provide a timer for new activations which updates on drop. | ||
| pub fn time_new_activations(&self) -> Option<metrics::prometheus::prometheus::HistogramTimer> { | ||
| self.0.as_ref().map(|metrics| metrics.new_activations_overall.start_timer()) | ||
| } | ||
|
|
||
| /// Provide a timer per relay parents which updates on drop. | ||
| pub fn time_new_activations_relay_parent( | ||
| &self, | ||
| ) -> Option<metrics::prometheus::prometheus::HistogramTimer> { | ||
| self.0 | ||
| .as_ref() | ||
| .map(|metrics| metrics.new_activations_per_relay_parent.start_timer()) | ||
| } | ||
|
|
||
| /// Provide a timer per availability core which updates on drop. | ||
| pub fn time_new_activations_availability_core( | ||
| &self, | ||
| ) -> Option<metrics::prometheus::prometheus::HistogramTimer> { | ||
| self.0 | ||
| .as_ref() | ||
| .map(|metrics| metrics.new_activations_per_availability_core.start_timer()) | ||
| } | ||
| } | ||
|
|
||
| impl metrics::Metrics for Metrics { | ||
| fn try_register(registry: &prometheus::Registry) -> Result<Self, prometheus::PrometheusError> { | ||
| let metrics = MetricsInner { | ||
| collations_generated_total: prometheus::register( | ||
| prometheus::Counter::new( | ||
| "polkadot_parachain_collations_generated_total", | ||
| "Number of collations generated." | ||
| )?, | ||
| registry, | ||
| )?, | ||
| new_activations_overall: prometheus::register( | ||
| prometheus::Histogram::with_opts( | ||
| prometheus::HistogramOpts::new( | ||
| "polkadot_parachain_collation_generation_new_activations", | ||
| "Time spent within fn handle_new_activations", | ||
| ) | ||
| )?, | ||
| registry, | ||
| )?, | ||
| new_activations_per_relay_parent: prometheus::register( | ||
| prometheus::Histogram::with_opts( | ||
| prometheus::HistogramOpts::new( | ||
| "polkadot_parachain_collation_generation_per_relay_parent", | ||
| "Time spent handling a particular relay parent within fn handle_new_activations" | ||
| ) | ||
| )?, | ||
| registry, | ||
| )?, | ||
| new_activations_per_availability_core: prometheus::register( | ||
| prometheus::Histogram::with_opts( | ||
| prometheus::HistogramOpts::new( | ||
| "polkadot_parachain_collation_generation_per_availability_core", | ||
| "Time spent handling a particular availability core for a relay parent in fn handle_new_activations", | ||
| ) | ||
| )?, | ||
| registry, | ||
| )?, | ||
| }; | ||
| Ok(Metrics(Some(metrics))) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.