Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated address formatting into prometheus #12

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 18 additions & 21 deletions challenger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub mod metrics;

use contract::{OpPokeChallengedSuccessfullyFilter, OpPokedFilter, ScribeOptimisticProvider};

use crate::metrics::{ERRORS_COUNTER, LAST_SCANNED_BLOCK_GAUGE};
use crate::metrics::{CHALLENGE_COUNTER, ERRORS_COUNTER, LAST_SCANNED_BLOCK_GAUGE};

// Note: this is true virtually all of the time but because of leap seconds not always.
// We take minimal time just to be sure, it's always better to check outdated blocks
Expand Down Expand Up @@ -171,12 +171,11 @@ where
// Updating last scanned block metric
LAST_SCANNED_BLOCK_GAUGE
.with_label_values(&[
&self.address.to_string(),
&self
.contract_provider
.get_from()
.unwrap_or_default()
.to_string(),
&format!("{:?}", self.address),
&format!(
"{:?}",
self.contract_provider.get_from().unwrap_or_default()
),
])
.set(latest_block_number.as_u64() as i64);

Expand Down Expand Up @@ -242,15 +241,14 @@ where
self.address, receipt
);
// Add challenge to metrics
LAST_SCANNED_BLOCK_GAUGE
CHALLENGE_COUNTER
.with_label_values(&[
&self.address.to_string(),
&self
.contract_provider
.get_from()
.unwrap_or_default()
.to_string(),
&receipt.transaction_hash.to_string(),
&format!("{:?}", self.address),
&format!(
"{:?}",
self.contract_provider.get_from().unwrap_or_default()
),
&format!("{:?}", receipt.transaction_hash),
])
.inc();
} else {
Expand Down Expand Up @@ -319,12 +317,11 @@ where

ERRORS_COUNTER
.with_label_values(&[
&self.address.to_string(),
&self
.contract_provider
.get_from()
.unwrap_or_default()
.to_string(),
&format!("{:?}", self.address),
&format!(
"{:?}",
self.contract_provider.get_from().unwrap_or_default()
),
&err.to_string(),
])
.inc();
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ async fn main() -> Result<()> {
if res.is_err() {
ERRORS_COUNTER
.with_label_values(&[
&address.to_string(),
&signer_address.to_string(),
&format!("{:?}", address),
&format!("{:?}", signer_address),
&res.err().unwrap().to_string(),
])
.inc();
Expand Down
Loading