-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(starknet_batcher): storage height metric
- Loading branch information
1 parent
cee26cb
commit 778c278
Showing
6 changed files
with
84 additions
and
5 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,31 @@ | ||
use metrics::{counter, describe_counter, Counter}; | ||
use starknet_api::block::BlockNumber; | ||
|
||
pub const STORAGE_HEIGHT: Metric = | ||
Metric { name: "batcher_storage_height", description: "The height of the batcher storage" }; | ||
|
||
pub struct Metric { | ||
pub name: &'static str, | ||
pub description: &'static str, | ||
} | ||
|
||
pub struct RegisteredMetrics { | ||
// Ideally, we would have a `Gauge` here because of reverts, but we can't because | ||
// the value will need to implement `Into<f64>` and `BlockNumber` doesn't. | ||
// In case of reverts, consider calling `absolute`. | ||
storage_height: Counter, | ||
} | ||
|
||
impl RegisteredMetrics { | ||
pub fn register_metrics(storage_height: BlockNumber) -> Self { | ||
let storage_height_metric = counter!(STORAGE_HEIGHT.name); | ||
describe_counter!(STORAGE_HEIGHT.name, STORAGE_HEIGHT.description); | ||
storage_height_metric.absolute(storage_height.0); | ||
|
||
Self { storage_height: storage_height_metric } | ||
} | ||
|
||
pub fn increment_storage_height(&self) { | ||
self.storage_height.increment(1); | ||
} | ||
} |