-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into importer-component
- Loading branch information
Showing
14 changed files
with
383 additions
and
350 deletions.
There are no files selected for viewing
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,67 @@ | ||
use std::net::SocketAddr; | ||
use std::stringify; | ||
|
||
use clap::Parser; | ||
use display_json::DebugAsJson; | ||
|
||
use crate::infra::metrics::metrics_for_consensus; | ||
use crate::infra::metrics::metrics_for_evm; | ||
use crate::infra::metrics::metrics_for_executor; | ||
use crate::infra::metrics::metrics_for_importer_online; | ||
use crate::infra::metrics::metrics_for_json_rpc; | ||
use crate::infra::metrics::metrics_for_rocks; | ||
use crate::infra::metrics::metrics_for_storage_read; | ||
use crate::infra::metrics::metrics_for_storage_write; | ||
|
||
#[derive(DebugAsJson, Clone, Parser, serde::Serialize)] | ||
pub struct MetricsConfig { | ||
/// Metrics exporter binding address. | ||
#[arg(long = "metrics-exporter-address", env = "METRICS_EXPORTER_ADDRESS", default_value = "0.0.0.0:9000")] | ||
pub metrics_exporter_address: SocketAddr, | ||
} | ||
|
||
impl MetricsConfig { | ||
/// Inits application global metrics exporter. | ||
pub fn init(&self) -> anyhow::Result<()> { | ||
tracing::info!(address = %self.metrics_exporter_address, "creating metrics exporter"); | ||
|
||
// get metric definitions | ||
let mut metrics = Vec::new(); | ||
metrics.extend(metrics_for_importer_online()); | ||
metrics.extend(metrics_for_json_rpc()); | ||
metrics.extend(metrics_for_executor()); | ||
metrics.extend(metrics_for_evm()); | ||
metrics.extend(metrics_for_storage_read()); | ||
metrics.extend(metrics_for_storage_write()); | ||
metrics.extend(metrics_for_rocks()); | ||
metrics.extend(metrics_for_consensus()); | ||
|
||
// init metric exporter | ||
init_metrics_exporter(self.metrics_exporter_address); | ||
|
||
// init metric description (always after provider started) | ||
for metric in &metrics { | ||
metric.register_description(); | ||
} | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
#[cfg(feature = "metrics")] | ||
fn init_metrics_exporter(address: SocketAddr) { | ||
tracing::info!(%address, "creating prometheus metrics exporter"); | ||
if let Err(e) = metrics_exporter_prometheus::PrometheusBuilder::new() | ||
.add_global_label("service", crate::infra::build_info::service_name()) | ||
.add_global_label("version", crate::infra::build_info::version()) | ||
.with_http_listener(address) | ||
.install() | ||
{ | ||
tracing::error!(reason = ?e, %address, "failed to create metrics exporter"); | ||
} | ||
} | ||
|
||
#[cfg(not(feature = "metrics"))] | ||
fn init_metrics_exporter(_: SocketAddr) { | ||
tracing::info!("creating noop metrics exporter"); | ||
} |
This file was deleted.
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
mod sentry_config; | ||
|
||
pub use sentry_config::SentryConfig; |
Oops, something went wrong.