mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-22 13:45:40 +00:00
Add a [prefix]_process_start_time_seconds metric (#6315)
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use std::convert::TryFrom;
|
use std::{convert::TryFrom, time::SystemTime};
|
||||||
|
|
||||||
use crate::NetworkStatus;
|
use crate::NetworkStatus;
|
||||||
use prometheus_endpoint::{register, Gauge, U64, F64, Registry, PrometheusError, Opts, GaugeVec};
|
use prometheus_endpoint::{register, Gauge, U64, F64, Registry, PrometheusError, Opts, GaugeVec};
|
||||||
@@ -79,6 +79,13 @@ impl PrometheusMetrics {
|
|||||||
|
|
||||||
register_globals(registry)?;
|
register_globals(registry)?;
|
||||||
|
|
||||||
|
let start_time_since_epoch = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH)
|
||||||
|
.unwrap_or_default();
|
||||||
|
register(Gauge::<U64>::new(
|
||||||
|
"process_start_time_seconds",
|
||||||
|
"Number of seconds between the UNIX epoch and the moment the process started",
|
||||||
|
)?, registry)?.set(start_time_since_epoch.as_secs());
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
// system
|
// system
|
||||||
#[cfg(all(any(unix, windows), not(target_os = "android")))]
|
#[cfg(all(any(unix, windows), not(target_os = "android")))]
|
||||||
|
|||||||
Reference in New Issue
Block a user