Skip to content

Commit

Permalink
refactor: enhance calls to the metrics service in the aggregator runn…
Browse files Browse the repository at this point in the history
…er, fix typos and renaming
  • Loading branch information
dlachaume committed Oct 21, 2024
1 parent 196a73e commit eefc17b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 35 deletions.
2 changes: 1 addition & 1 deletion mithril-aggregator/src/commands/serve_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ impl ServeCommand {
let metrics_service = dependencies_builder
.get_metrics_service()
.await
.with_context(|| "metric service initialization error")?;
.with_context(|| "Metrics service initialization error")?;
let (metrics_server_shutdown_tx, metrics_server_shutdown_rx) = oneshot::channel();
if config.enable_metrics_server {
let metrics_logger = root_logger.clone();
Expand Down
22 changes: 11 additions & 11 deletions mithril-aggregator/src/metrics/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ build_metrics_service!(
),
artifact_detail_cardano_db_total_served_since_startup:MetricCounter(
"mithril_aggregator_artifact_detail_cardano_db_total_served_since_startup_counter",
"Number of cardano db artifact details served since startup on a Mithril aggregator node"
"Number of Cardano db artifact details served since startup on a Mithril aggregator node"
),
artifact_detail_mithril_stake_distribution_total_served_since_startup:MetricCounter(
"mithril_aggregator_artifact_detail_mithril_stake_distribution_total_served_since_startup_counter",
"Number of mithril stake distribution artifact details served since startup on a Mithril aggregator node"
"Number of Mithril stake distribution artifact details served since startup on a Mithril aggregator node"
),
artifact_detail_cardano_stake_distribution_total_served_since_startup:MetricCounter(
"mithril_aggregator_artifact_detail_cardano_stake_distribution_total_served_since_startup_counter",
"Number of cardano stake distribution artifact details served since startup on a Mithril aggregator node"
"Number of Cardano stake distribution artifact details served since startup on a Mithril aggregator node"
),
artifact_detail_cardano_transaction_total_served_since_startup:MetricCounter(
"mithril_aggregator_artifact_detail_cardano_transaction_total_served_since_startup_counter",
"Number of cardano transaction artifact details served since startup on a Mithril aggregator node"
"Number of Cardano transaction artifact details served since startup on a Mithril aggregator node"
),
proof_cardano_transaction_total_served_since_startup:MetricCounter(
"mithril_aggregator_proof_cardano_transaction_total_served_since_startup_counter",
"Number of cardano transaction proofs served since startup on a Mithril aggregator node"
"Number of Cardano transaction proofs served since startup on a Mithril aggregator node"
),
signer_registration_total_received_since_startup:MetricCounter(
"mithril_aggregator_signer_registration_total_received_since_startup_counter",
Expand All @@ -42,27 +42,27 @@ build_metrics_service!(
),
artifact_cardano_db_total_produced_since_startup:MetricCounter(
"mithril_aggregator_artifact_cardano_db_total_produced_since_startup_counter",
"Number of cardano db artifacts produced since startup on a Mithril aggregator node"
"Number of Cardano db artifacts produced since startup on a Mithril aggregator node"
),
artifact_mithril_stake_distribution_total_produced_since_startup:MetricCounter(
"mithril_aggregator_artifact_mithril_stake_distribution_total_produced_since_startup_counter",
"Number of mithril stake distribution artifacts produced since startup on a Mithril aggregator node"
"Number of Mithril stake distribution artifacts produced since startup on a Mithril aggregator node"
),
artifact_cardano_stake_distribution_total_produced_since_startup:MetricCounter(
"mithril_aggregator_artifact_cardano_stake_distribution_total_produced_since_startup_counter",
"Number of cardano stake distribution artifacts produced since startup on a Mithril aggregator node"
"Number of Cardano stake distribution artifacts produced since startup on a Mithril aggregator node"
),
artifact_cardano_transaction_total_produced_since_startup:MetricCounter(
"mithril_aggregator_artifact_cardano_transaction_total_produced_since_startup_counter",
"Number of cardano transaction artifacts produced since startup on a Mithril aggregator node"
"Number of Cardano transaction artifacts produced since startup on a Mithril aggregator node"
),
runtime_cycle_success_since_startup:MetricCounter(
"mithril_aggregator_runtime_cycle_success_since_startup_counter",
"Number of successful runtime cycles since startup on a Mithril signer aggregator"
"Number of successful runtime cycles since startup on a Mithril aggregator"
),
runtime_cycle_total_since_startup:MetricCounter(
"mithril_aggregator_runtime_cycle_total_since_startup_counter",
"Number of runtime cycles since startup on a Mithril signer aggregator"
"Number of runtime cycles since startup on a Mithril aggregator"
)

);
33 changes: 12 additions & 21 deletions mithril-aggregator/src/runtime/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,32 +177,23 @@ impl AggregatorRunner {
&self,
signed_entity_type: &SignedEntityType,
) {
match signed_entity_type {
let metrics = self.dependencies.metrics_service.clone();
let metric_counter = match signed_entity_type {
SignedEntityType::MithrilStakeDistribution(_) => {
self.dependencies
.metrics_service
.get_artifact_mithril_stake_distribution_total_produced_since_startup()
.increment();
metrics.get_artifact_mithril_stake_distribution_total_produced_since_startup()
}
SignedEntityType::CardanoImmutableFilesFull(_) => {
self.dependencies
.metrics_service
.get_artifact_cardano_db_total_produced_since_startup()
.increment();
metrics.get_artifact_cardano_db_total_produced_since_startup()
}
SignedEntityType::CardanoStakeDistribution(_) => {
self.dependencies
.metrics_service
.get_artifact_cardano_stake_distribution_total_produced_since_startup()
.increment();
metrics.get_artifact_cardano_stake_distribution_total_produced_since_startup()
}
SignedEntityType::CardanoTransactions(_, _) => {
self.dependencies
.metrics_service
.get_artifact_cardano_transaction_total_produced_since_startup()
.increment();
metrics.get_artifact_cardano_transaction_total_produced_since_startup()
}
}
};

metric_counter.increment();
}
}

Expand Down Expand Up @@ -430,16 +421,16 @@ impl AggregatorRunnerTrait for AggregatorRunner {
format!(
"CertifierService can not create certificate for signed_entity_type: '{signed_entity_type}'"
)
});
})?;

if let Ok(Some(_)) = &certificate {
if certificate.is_some() {
self.dependencies
.metrics_service
.get_certificate_total_produced_since_startup()
.increment();
}

certificate
Ok(certificate)
}

async fn create_artifact(
Expand Down
2 changes: 0 additions & 2 deletions mithril-aggregator/tests/test_extensions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ mod metrics_tester;

pub use aggregator_observer::AggregatorObserver;
pub use expected_certificate::ExpectedCertificate;
// There are several tests where it's not necessary to verify the metrics
#[allow(unused_imports)]
pub use metrics_tester::ExpectedMetrics;
pub use metrics_tester::MetricsVerifier;
pub use runtime_tester::RuntimeTester;

0 comments on commit eefc17b

Please sign in to comment.