Skip to content

Commit

Permalink
Fix metrics prefix naming (#1453)
Browse files Browse the repository at this point in the history
  • Loading branch information
broody authored Jan 17, 2024
1 parent bc6a5c1 commit cd410f9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/katana/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}

if let Some(listen_addr) = config.metrics {
let prometheus_handle = prometheus_exporter::install_recorder()?;
let prometheus_handle = prometheus_exporter::install_recorder("katana")?;

info!(target: "katana::cli", addr = %listen_addr, "Starting metrics endpoint");
prometheus_exporter::serve(
Expand Down
4 changes: 2 additions & 2 deletions crates/metrics/src/prometheus_exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ pub(crate) trait Hook: Fn() + Send + Sync {}
impl<T: Fn() + Send + Sync> Hook for T {}

/// Installs Prometheus as the metrics recorder.
pub fn install_recorder() -> anyhow::Result<PrometheusHandle> {
pub fn install_recorder(prefix: &str) -> anyhow::Result<PrometheusHandle> {
let recorder = PrometheusBuilder::new().build_recorder();
let handle = recorder.handle();

// Build metrics stack
Stack::new(recorder)
.push(PrefixLayer::new("katana"))
.push(PrefixLayer::new(prefix))
.install()
.map_err(|e| anyhow::anyhow!("Couldn't set metrics recorder: {}", e))?;

Expand Down
2 changes: 1 addition & 1 deletion crates/torii/server/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ async fn main() -> anyhow::Result<()> {
info!(target: "torii::cli", "Serving Graphql playground: {}\n", format!("http://{}/graphql", args.addr));

if let Some(listen_addr) = args.metrics {
let prometheus_handle = prometheus_exporter::install_recorder()?;
let prometheus_handle = prometheus_exporter::install_recorder("torii")?;

info!(target: "torii::cli", addr = %listen_addr, "Starting metrics endpoint");
prometheus_exporter::serve(
Expand Down

0 comments on commit cd410f9

Please sign in to comment.