|
|
@@ -16,8 +16,18 @@ import (
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"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"
|
|
|
|
|
|
var (
|
|
|
@@ -98,9 +108,22 @@ func LongVersionFor(program string) string {
|
|
|
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)
|
|
|
|
|
|
- if tags := TagsList(); len(tags) > 0 {
|
|
|
+ tags := TagsList()
|
|
|
+ if len(tags) > 0 {
|
|
|
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
|
|
|
}
|
|
|
|