mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 05:57:03 +09:00
30 lines
742 B
Go
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
|
|
}
|