Skip to content

Commit

Permalink
Merge pull request #2270 from mcdee/process-start-time-metric
Browse files Browse the repository at this point in the history
Add process_start_time_seconds metric
  • Loading branch information
kkovaacs authored Sep 27, 2024
2 parents d8cc94a + fb30f35 commit 646c304
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Pathfinder now fetches data concurrently from the feeder gateway when catching up. The `--gateway.fetch-concurrency` CLI option can be used to limit how many blocks are fetched concurrently (the default is 8).
- `--disable-version-update-check` CLI option has been added to disable the periodic checking for a new version.
- add `process_start_time_seconds` metric showing the unix timestamp when the process started.

### Changed

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ This endpoint is useful for Docker nodes which only want to present themselves a

`/metrics` provides a [Prometheus](https://prometheus.io/) metrics scrape endpoint. Currently the following metrics are available:

#### Process metrics

- `process_start_time_seconds` provides the unix timestamp at which pathfinder started

#### RPC related counters

- `rpc_method_calls_total`,
Expand Down
6 changes: 6 additions & 0 deletions crates/pathfinder/src/bin/pathfinder/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::num::NonZeroU32;
use std::path::PathBuf;
use std::sync::atomic::AtomicBool;
use std::sync::Arc;
use std::time::{SystemTime, UNIX_EPOCH};

use anyhow::Context;
use metrics_exporter_prometheus::PrometheusBuilder;
Expand Down Expand Up @@ -642,6 +643,11 @@ async fn spawn_monitoring(

metrics::gauge!("pathfinder_build_info", 1.0, "version" => VERGEN_GIT_DESCRIBE);

match SystemTime::now().duration_since(UNIX_EPOCH) {
Ok(duration) => metrics::gauge!("process_start_time_seconds", duration.as_secs() as f64),
Err(err) => tracing::error!("Failed to read system time: {:?}", err),
}

let (_, handle) =
monitoring::spawn_server(address, readiness, sync_state, prometheus_handle).await?;
Ok(handle)
Expand Down

0 comments on commit 646c304

Please sign in to comment.