-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactoring: introduce Params in network worker * Initial metrics in subcoin-network * Initial metrics in sc-consensus-nakamoto * Spawn prometheus service in import-blocks command * Use GaugeVec for block_execution_time * Rename --bootnode to --seednodes in subcoin networking params * More subcoin network metrics * Fix test * FMT * Add block transactions count metric * Add docker * Add dashboard.json * Add README.md * Update grafana README.md * . * Update dashboard.json * Add block size metric * Update readme (#38) * Update README.md * Update README.md * Update README.md * . * . * . * Update README.md * Update README.md * Update README.md * Rate limiting on metric report of block_execution
- Loading branch information
1 parent
5531c21
commit 41535b4
Showing
23 changed files
with
1,206 additions
and
84 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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 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 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,60 @@ | ||
use substrate_prometheus_endpoint::{register, GaugeVec, Opts, PrometheusError, Registry, U64}; | ||
|
||
pub struct Metrics { | ||
block_execution_time: GaugeVec<U64>, | ||
block_transactions_count: GaugeVec<U64>, | ||
block_size: GaugeVec<U64>, | ||
} | ||
|
||
impl Metrics { | ||
pub fn register(registry: &Registry) -> Result<Self, PrometheusError> { | ||
Ok(Self { | ||
block_execution_time: register( | ||
GaugeVec::new( | ||
Opts::new( | ||
"subcoin_block_execution_time_milliseconds", | ||
"Time taken to execute a block in milliseconds", | ||
), | ||
&["block_height"], | ||
)?, | ||
registry, | ||
)?, | ||
block_transactions_count: register( | ||
GaugeVec::new( | ||
Opts::new( | ||
"subcoin_block_transactions_count", | ||
"Number of transactions in the block", | ||
), | ||
&["block_height"], | ||
)?, | ||
registry, | ||
)?, | ||
block_size: register( | ||
GaugeVec::new( | ||
Opts::new("subcoin_block_size", "Block size in bytes"), | ||
&["block_height"], | ||
)?, | ||
registry, | ||
)?, | ||
}) | ||
} | ||
|
||
pub fn report_block_execution( | ||
&self, | ||
block_height: u32, | ||
transactions_count: usize, | ||
block_size: usize, | ||
execution_time: u128, | ||
) { | ||
let block_height = block_height.to_string(); | ||
self.block_transactions_count | ||
.with_label_values(&[&block_height]) | ||
.set(transactions_count as u64); | ||
self.block_size | ||
.with_label_values(&[&block_height]) | ||
.set(block_size as u64); | ||
self.block_execution_time | ||
.with_label_values(&[&block_height]) | ||
.set(execution_time as u64); | ||
} | ||
} |
This file contains 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 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.