chore: systematic syncthing_build_info metric
Signed-off-by: Jakob Borg <jakob@kastelo.net>
This commit is contained in:
@@ -101,6 +101,8 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.SetOutput(os.Stdout)
|
log.SetOutput(os.Stdout)
|
||||||
|
log.Println(build.LongVersionFor("stcrashreceiver"))
|
||||||
|
|
||||||
if err := http.ListenAndServe(params.Listen, mux); err != nil {
|
if err := http.ListenAndServe(params.Listen, mux); err != nil {
|
||||||
log.Fatalln("HTTP serve:", err)
|
log.Fatalln("HTTP serve:", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import (
|
|||||||
|
|
||||||
"github.com/syncthing/syncthing/cmd/infra/strelaypoolsrv/auto"
|
"github.com/syncthing/syncthing/cmd/infra/strelaypoolsrv/auto"
|
||||||
"github.com/syncthing/syncthing/lib/assets"
|
"github.com/syncthing/syncthing/lib/assets"
|
||||||
|
"github.com/syncthing/syncthing/lib/build"
|
||||||
"github.com/syncthing/syncthing/lib/geoip"
|
"github.com/syncthing/syncthing/lib/geoip"
|
||||||
"github.com/syncthing/syncthing/lib/protocol"
|
"github.com/syncthing/syncthing/lib/protocol"
|
||||||
"github.com/syncthing/syncthing/lib/rand"
|
"github.com/syncthing/syncthing/lib/rand"
|
||||||
@@ -146,6 +147,8 @@ func main() {
|
|||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
log.Println(build.LongVersionFor("strelaypoolsrv"))
|
||||||
|
|
||||||
requests = make(chan request, requestQueueLen)
|
requests = make(chan request, requestQueueLen)
|
||||||
geoip, err := geoip.NewGeoLite2CityProvider(context.Background(), geoipAccountID, geoipLicenseKey, os.TempDir())
|
geoip, err := geoip.NewGeoLite2CityProvider(context.Background(), geoipAccountID, geoipLicenseKey, os.TempDir())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import (
|
|||||||
"github.com/alecthomas/kong"
|
"github.com/alecthomas/kong"
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
"github.com/syncthing/syncthing/internal/slogutil"
|
"github.com/syncthing/syncthing/internal/slogutil"
|
||||||
|
"github.com/syncthing/syncthing/lib/build"
|
||||||
"github.com/syncthing/syncthing/lib/httpcache"
|
"github.com/syncthing/syncthing/lib/httpcache"
|
||||||
"github.com/syncthing/syncthing/lib/upgrade"
|
"github.com/syncthing/syncthing/lib/upgrade"
|
||||||
)
|
)
|
||||||
@@ -44,6 +45,8 @@ func main() {
|
|||||||
Level: slog.LevelInfo,
|
Level: slog.LevelInfo,
|
||||||
})))
|
})))
|
||||||
|
|
||||||
|
slog.Info(build.LongVersionFor("stupgrades"))
|
||||||
|
|
||||||
if err := server(¶ms); err != nil {
|
if err := server(¶ms); err != nil {
|
||||||
fmt.Printf("Error: %v\n", err)
|
fmt.Printf("Error: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import (
|
|||||||
|
|
||||||
"github.com/alecthomas/kong"
|
"github.com/alecthomas/kong"
|
||||||
"github.com/syncthing/syncthing/cmd/infra/ursrv/serve"
|
"github.com/syncthing/syncthing/cmd/infra/ursrv/serve"
|
||||||
|
"github.com/syncthing/syncthing/lib/build"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CLI struct {
|
type CLI struct {
|
||||||
@@ -24,6 +25,8 @@ func main() {
|
|||||||
Level: slog.LevelInfo,
|
Level: slog.LevelInfo,
|
||||||
})))
|
})))
|
||||||
|
|
||||||
|
slog.Info(build.LongVersionFor("ursrv"))
|
||||||
|
|
||||||
var cli CLI
|
var cli CLI
|
||||||
ctx := kong.Parse(&cli)
|
ctx := kong.Parse(&cli)
|
||||||
if err := ctx.Run(); err != nil {
|
if err := ctx.Run(); err != nil {
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"runtime"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/alecthomas/kong"
|
"github.com/alecthomas/kong"
|
||||||
@@ -96,8 +95,6 @@ func main() {
|
|||||||
}
|
}
|
||||||
slog.Info(build.LongVersionFor("stdiscosrv"))
|
slog.Info(build.LongVersionFor("stdiscosrv"))
|
||||||
|
|
||||||
buildInfo.WithLabelValues(build.Version, runtime.Version(), build.User, build.Date.UTC().Format("2006-01-02T15:04:05Z")).Set(1)
|
|
||||||
|
|
||||||
var cert tls.Certificate
|
var cert tls.Certificate
|
||||||
if !cli.HTTP {
|
if !cli.HTTP {
|
||||||
var err error
|
var err error
|
||||||
|
|||||||
@@ -11,14 +11,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
buildInfo = prometheus.NewGaugeVec(
|
|
||||||
prometheus.GaugeOpts{
|
|
||||||
Namespace: "syncthing",
|
|
||||||
Subsystem: "discovery",
|
|
||||||
Name: "build_info",
|
|
||||||
Help: "A metric with a constant '1' value labeled by version, goversion, builduser and builddate from which stdiscosrv was built.",
|
|
||||||
}, []string{"version", "goversion", "builduser", "builddate"})
|
|
||||||
|
|
||||||
apiRequestsTotal = prometheus.NewCounterVec(
|
apiRequestsTotal = prometheus.NewCounterVec(
|
||||||
prometheus.CounterOpts{
|
prometheus.CounterOpts{
|
||||||
Namespace: "syncthing",
|
Namespace: "syncthing",
|
||||||
@@ -132,7 +124,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
prometheus.MustRegister(buildInfo,
|
prometheus.MustRegister(
|
||||||
apiRequestsTotal, apiRequestsSeconds,
|
apiRequestsTotal, apiRequestsSeconds,
|
||||||
lookupRequestsTotal, announceRequestsTotal,
|
lookupRequestsTotal, announceRequestsTotal,
|
||||||
replicationSendsTotal, replicationRecvsTotal,
|
replicationSendsTotal, replicationRecvsTotal,
|
||||||
|
|||||||
+24
-1
@@ -16,8 +16,18 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var buildInfo = promauto.NewGaugeVec(prometheus.GaugeOpts{
|
||||||
|
Namespace: "syncthing",
|
||||||
|
Subsystem: "build",
|
||||||
|
Name: "info",
|
||||||
|
Help: "A metric with a constant '1' value labeled by version information from when the binary was built.",
|
||||||
|
}, []string{"program", "version", "codename", "goversion", "builduser", "builddate", "tags"})
|
||||||
|
|
||||||
const Codename = "Hafnium Hornet"
|
const Codename = "Hafnium Hornet"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -98,9 +108,22 @@ func LongVersionFor(program string) string {
|
|||||||
date := Date.UTC().Format("2006-01-02 15:04:05 MST")
|
date := Date.UTC().Format("2006-01-02 15:04:05 MST")
|
||||||
v := fmt.Sprintf(`%s %s "%s" (%s %s-%s) %s@%s %s`, program, Version, Codename, runtime.Version(), runtime.GOOS, runtime.GOARCH, User, Host, date)
|
v := fmt.Sprintf(`%s %s "%s" (%s %s-%s) %s@%s %s`, program, Version, Codename, runtime.Version(), runtime.GOOS, runtime.GOARCH, User, Host, date)
|
||||||
|
|
||||||
if tags := TagsList(); len(tags) > 0 {
|
tags := TagsList()
|
||||||
|
if len(tags) > 0 {
|
||||||
v = fmt.Sprintf("%s [%s]", v, strings.Join(tags, ", "))
|
v = fmt.Sprintf("%s [%s]", v, strings.Join(tags, ", "))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildInfo.Reset()
|
||||||
|
buildInfo.With(prometheus.Labels{
|
||||||
|
"program": program,
|
||||||
|
"version": Version,
|
||||||
|
"codename": Codename,
|
||||||
|
"goversion": runtime.Version(),
|
||||||
|
"builduser": fmt.Sprintf("%s@%s", User, Host),
|
||||||
|
"builddate": Date.UTC().Format("2006-01-02 15:04:05 MST"),
|
||||||
|
"tags": strings.Join(tags, ","),
|
||||||
|
}).Set(1)
|
||||||
|
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
<configuration version="51">
|
<configuration version="52">
|
||||||
<folder id="default" label="" path="s2" type="sendreceive" rescanIntervalS="60" fsWatcherEnabled="false" fsWatcherDelayS="10" fsWatcherTimeoutS="0" ignorePerms="false" autoNormalize="true">
|
<folder id="default" label="" path="s2" type="sendreceive" rescanIntervalS="60" fsWatcherEnabled="false" fsWatcherDelayS="10" fsWatcherTimeoutS="0" ignorePerms="false" autoNormalize="true">
|
||||||
<filesystemType>basic</filesystemType>
|
<filesystemType>basic</filesystemType>
|
||||||
<device id="I6KAH76-66SLLLB-5PFXSOA-UFJCDZC-YAOMLEK-CP2GB32-BV5RQST-3PSROAU" introducedBy="">
|
<device id="I6KAH76-66SLLLB-5PFXSOA-UFJCDZC-YAOMLEK-CP2GB32-BV5RQST-3PSROAU" introducedBy="">
|
||||||
|
|||||||
Reference in New Issue
Block a user