1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-07 21:47:02 +09:00
any-sync/metric/version.go
2023-05-23 14:47:24 +02:00

30 lines
742 B
Go

package metric
import (
"github.com/anyproto/any-sync/app"
"github.com/prometheus/client_golang/prometheus"
)
func newVersionsCollector(a *app.App) prometheus.Collector {
return &versionCollector{prometheus.MustNewConstMetric(prometheus.NewDesc(
"anysync_versions",
"Build information about the main Go module.",
nil, prometheus.Labels{
"anysync_version": a.AnySyncVersion(),
"app_name": a.AppName(),
"app_version": a.Version(),
},
), prometheus.GaugeValue, 1)}
}
type versionCollector struct {
ver prometheus.Metric
}
func (v *versionCollector) Describe(descs chan<- *prometheus.Desc) {
descs <- v.ver.Desc()
}
func (v *versionCollector) Collect(metrics chan<- prometheus.Metric) {
metrics <- v.ver
}