Add a build info metric (#323)

* Add a build info metric

Add a standard Prometheus build info metric to make monitoring rollouts
easier.

* Update prometheus vendoring.

* Fix build error

Fix missing bool in builtinMetricMaps.

Signed-off-by: Ben Kochie <superq@gmail.com>
This commit is contained in:
Ben Kochie
2019-11-25 07:16:24 -06:00
committed by Will Rouesnel
parent 03013dea2e
commit aeec47ead4
87 changed files with 6753 additions and 4378 deletions

View File

@@ -119,6 +119,31 @@ var goDirs []string
var goPkgs []string
var goCmds []string
var branch = func() string {
if v := os.Getenv("BRANCH"); v != "" {
return v
}
out, _ := sh.Output("git", "rev-parse", "--abbrev-ref", "HEAD")
return out
}()
var buildDate = func() string {
if v := os.Getenv("BUILDDATE"); v != "" {
return v
}
return time.Now().Format("2006-01-02T15:04:05-0700")
}()
var revision = func() string {
if v := os.Getenv("REVISION"); v != "" {
return v
}
out, _ := sh.Output("git", "rev-parse", "HEAD")
return out
}()
var version = func() string {
if v := os.Getenv("VERSION"); v != "" {
return v
@@ -533,7 +558,11 @@ func IntegrationTestBinary() error {
if (changed && (err == nil)) || os.IsNotExist(err) {
return sh.RunWith(map[string]string{"CGO_ENABLED": "0"}, "go", "test", "./cmd/postgres_exporter",
"-c", "-tags", "integration",
"-a", "-ldflags", "-extldflags '-static'", "-X", fmt.Sprintf("main.Version=%s", version),
"-a", "-ldflags", "-extldflags '-static'",
"-X", fmt.Sprintf("main.Branch=%s", branch),
"-X", fmt.Sprintf("main.BuildDate=%s", buildDate),
"-X", fmt.Sprintf("main.Revision=%s", revision),
"-X", fmt.Sprintf("main.VersionShort=%s", versionShort),
"-o", "postgres_exporter_integration_test", "-cover", "-covermode", "count")
}
return err