1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-09 09:35:03 +09:00

app.AnySyncVersion

This commit is contained in:
Sergey Cherepanov 2023-05-18 13:31:53 +02:00 committed by Mikhail Iudin
parent 0d72b3b671
commit b1ad0be3b4
No known key found for this signature in database
GPG key ID: FAAAA8BAABDFF1C0
2 changed files with 26 additions and 19 deletions

View file

@ -3,7 +3,6 @@ package metric
import (
"github.com/anytypeio/any-sync/app"
"github.com/prometheus/client_golang/prometheus"
"runtime/debug"
)
func newVersionsCollector(a *app.App) prometheus.Collector {
@ -11,25 +10,13 @@ func newVersionsCollector(a *app.App) prometheus.Collector {
"anysync_versions",
"Build information about the main Go module.",
nil, prometheus.Labels{
"anysync_version": anySyncVerion(),
"anysync_version": a.AnySyncVersion(),
"app_name": a.AppName(),
"app_version": a.Version(),
},
), prometheus.GaugeValue, 1)}
}
func anySyncVerion() string {
info, ok := debug.ReadBuildInfo()
if ok {
for _, mod := range info.Deps {
if mod.Path == "github.com/anytypeio/any-sync" {
return mod.Version
}
}
}
return ""
}
type versionCollector struct {
ver prometheus.Metric
}