Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add platform info to labels #403

Merged
merged 1 commit into from Dec 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions version/info.go
Expand Up @@ -31,6 +31,8 @@ var (
BuildUser string
BuildDate string
GoVersion = runtime.Version()
GoOS = runtime.GOOS
GoArch = runtime.GOARCH
)

// NewCollector returns a collector that exports metrics about current version
Expand All @@ -41,14 +43,16 @@ func NewCollector(program string) prometheus.Collector {
Namespace: program,
Name: "build_info",
Help: fmt.Sprintf(
"A metric with a constant '1' value labeled by version, revision, branch, and goversion from which %s was built.",
"A metric with a constant '1' value labeled by version, revision, branch, goversion from which %s was built, and the goos and goarch for the build.",
program,
),
ConstLabels: prometheus.Labels{
"version": Version,
"revision": getRevision(),
"branch": Branch,
"goversion": GoVersion,
"goos": GoOS,
"goarch": GoArch,
},
},
func() float64 { return 1 },
Expand All @@ -74,7 +78,7 @@ func Print(program string) string {
"buildUser": BuildUser,
"buildDate": BuildDate,
"goVersion": GoVersion,
"platform": runtime.GOOS + "/" + runtime.GOARCH,
"platform": GoOS + "/" + GoArch,
}
t := template.Must(template.New("version").Parse(versionInfoTmpl))

Expand All @@ -90,7 +94,7 @@ func Info() string {
return fmt.Sprintf("(version=%s, branch=%s, revision=%s)", Version, Branch, getRevision())
}

// BuildContext returns goVersion, buildUser and buildDate information.
// BuildContext returns goVersion, platform, buildUser and buildDate information.
func BuildContext() string {
return fmt.Sprintf("(go=%s, user=%s, date=%s)", GoVersion, BuildUser, BuildDate)
return fmt.Sprintf("(go=%s, platform=%s, user=%s, date=%s)", GoVersion, GoOS+"/"+GoArch, BuildUser, BuildDate)
}