Skip to content

Commit

Permalink
prefix prometheus metrics with chainhook_
Browse files Browse the repository at this point in the history
  • Loading branch information
MicaiahReid committed Feb 8, 2024
1 parent ace447d commit dd6f4b1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions components/chainhook-cli/src/service/tests/observer_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ async fn prometheus_endpoint_returns_encoded_metrics() {
redis_process.kill().unwrap();
panic!("test failed with error: {e}");
});
const EXPECTED: &'static str = "# HELP stx_registered_predicates The number of Stacks predicates that have been registered by the Chainhook node.\n# TYPE stx_registered_predicates gauge\nstx_registered_predicates 1\n";
assert!(metrics.ends_with(EXPECTED));
const EXPECTED: &'static str = "# HELP chainhook_stx_registered_predicates The number of Stacks predicates that have been registered by the Chainhook node.\n# TYPE chainhook_stx_registered_predicates gauge\nchainhook_stx_registered_predicates 1\n";
assert!(metrics.contains(EXPECTED));

std::fs::remove_dir_all(&working_dir).unwrap();
flush_redis(redis_port);
Expand Down
28 changes: 14 additions & 14 deletions components/chainhook-sdk/src/monitoring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,75 +40,75 @@ impl PrometheusMonitoring {
let registry = Registry::new();
let stx_highest_block_ingested = PrometheusMonitoring::create_and_register_uint64_gauge(
&registry,
"stx_highest_block_ingested",
"chainhook_stx_highest_block_ingested",
"The highest Stacks block ingested by the Chainhook node.",
);
let stx_last_reorg_timestamp = PrometheusMonitoring::create_and_register_int_gauge(
&registry,
"stx_last_reorg_timestamp",
"chainhook_stx_last_reorg_timestamp",
"The timestamp of the latest Stacks reorg ingested by the Chainhook node.",
);
let stx_last_reorg_applied_blocks = PrometheusMonitoring::create_and_register_uint64_gauge(
&registry,
"stx_last_reorg_applied_blocks",
"chainhook_stx_last_reorg_applied_blocks",
"The number of blocks applied to the Stacks chain as part of the latest Stacks reorg.",
);
let stx_last_reorg_rolled_back_blocks =
PrometheusMonitoring::create_and_register_uint64_gauge(
&registry,
"stx_last_reorg_rolled_back_blocks",
"chainhook_stx_last_reorg_rolled_back_blocks",
"The number of blocks rolled back from the Stacks chain as part of the latest Stacks reorg.",
);
let stx_last_block_ingestion_time = PrometheusMonitoring::create_and_register_uint64_gauge(
&registry,
"stx_last_block_ingestion_time",
"chainhook_stx_last_block_ingestion_time",
"The time that the Chainhook node last ingested a Stacks block.",
);
let stx_registered_predicates = PrometheusMonitoring::create_and_register_uint64_gauge(
&registry,
"stx_registered_predicates",
"chainhook_stx_registered_predicates",
"The number of Stacks predicates that have been registered by the Chainhook node.",
);
let stx_deregistered_predicates = PrometheusMonitoring::create_and_register_uint64_gauge(
&registry,
"stx_deregistered_predicates",
"chainhook_stx_deregistered_predicates",
"The number of Stacks predicates that have been deregistered by the Chainhook node.",
);
let btc_highest_block_ingested = PrometheusMonitoring::create_and_register_uint64_gauge(
&registry,
"btc_highest_block_ingested",
"chainhook_btc_highest_block_ingested",
"The highest Bitcoin block ingested by the Chainhook node.",
);
let btc_last_reorg_timestamp = PrometheusMonitoring::create_and_register_int_gauge(
&registry,
"btc_last_reorg_timestamp",
"chainhook_btc_last_reorg_timestamp",
"The timestamp of the latest Bitcoin reorg ingested by the Chainhook node.",
);
let btc_last_reorg_applied_blocks =
PrometheusMonitoring::create_and_register_uint64_gauge(
&registry,
"btc_last_reorg_applied_blocks",
"chainhook_btc_last_reorg_applied_blocks",
"The number of blocks applied to the Bitcoin chain as part of the latest Bitcoin reorg.",
);
let btc_last_reorg_rolled_back_blocks =
PrometheusMonitoring::create_and_register_uint64_gauge(
&registry,
"btc_last_reorg_rolled_back_blocks",
"chainhook_btc_last_reorg_rolled_back_blocks",
"The number of blocks rolled back from the Bitcoin chain as part of the latest Bitcoin reorg.",
);
let btc_last_block_ingestion_time = PrometheusMonitoring::create_and_register_uint64_gauge(
&registry,
"btc_last_block_ingestion_time",
"chainhook_btc_last_block_ingestion_time",
"The time that the Chainhook node last ingested a Bitcoin block.",
);
let btc_registered_predicates = PrometheusMonitoring::create_and_register_uint64_gauge(
&registry,
"btc_registered_predicates",
"chainhook_btc_registered_predicates",
"The number of Bitcoin predicates that have been registered by the Chainhook node.",
);
let btc_deregistered_predicates = PrometheusMonitoring::create_and_register_uint64_gauge(
&registry,
"btc_deregistered_predicates",
"chainhook_btc_deregistered_predicates",
"The number of Bitcoin predicates that have been deregistered by the Chainhook node.",
);

Expand Down

0 comments on commit dd6f4b1

Please sign in to comment.