Skip to content

Commit

Permalink
feat: add start time metric (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
freak12techno authored Jan 5, 2024
1 parent 449db1a commit 0ebe629
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type Manager struct {
reporterQueriesCounter *prometheus.CounterVec

appVersionGauge *prometheus.GaugeVec
startTimeGauge *prometheus.GaugeVec
chainInfoGauge *prometheus.GaugeVec
}

Expand Down Expand Up @@ -87,6 +88,10 @@ func NewManager(logger *zerolog.Logger, config configPkg.MetricsConfig) *Manager
Name: constants.PrometheusMetricsPrefix + "version",
Help: "App version",
}, []string{"version"}),
startTimeGauge: promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: constants.PrometheusMetricsPrefix + "start_time",
Help: "Unix timestamp on when the app was started. Useful for annotations.",
}, []string{}),
eventsTotalCounter: promauto.NewCounterVec(prometheus.CounterOpts{
Name: constants.PrometheusMetricsPrefix + "events_total",
Help: "WebSocket events received by node",
Expand All @@ -111,6 +116,10 @@ func NewManager(logger *zerolog.Logger, config configPkg.MetricsConfig) *Manager
}

func (m *Manager) SetAllDefaultMetrics(chains []*configTypes.Chain) {
m.startTimeGauge.
With(prometheus.Labels{}).
Set(float64(time.Now().Unix()))

for _, chain := range chains {
m.SetDefaultMetrics(chain)
}
Expand Down

0 comments on commit 0ebe629

Please sign in to comment.