// VulcanizeDB // Copyright © 2022 Vulcanize // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . package prom import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" ) const ( namespace = "ipld_eth_state_snapshot" connSubsystem = "connections" statsSubsystem = "stats" ) var ( metrics bool lastValidatedBlock prometheus.Gauge ) func Init() { metrics = true lastValidatedBlock = promauto.NewGauge(prometheus.GaugeOpts{ Namespace: namespace, Subsystem: statsSubsystem, Name: "last_validated_block", Help: "Last validated block number", }) } // RegisterDBCollector create metric collector for given connection func RegisterDBCollector(name string, db DBStatsGetter) { if metrics { prometheus.Register(NewDBStatsCollector(name, db)) } } // SetLastValidatedBlock sets the last validated block number func SetLastValidatedBlock(blockNumber float64) { if metrics { lastValidatedBlock.Set(blockNumber) } }