3131 BuildUser string
3232 BuildDate string
3333 GoVersion = runtime .Version ()
34+ GoOS = runtime .GOOS
35+ GoArch = runtime .GOARCH
3436)
3537
3638// NewCollector returns a collector that exports metrics about current version
@@ -41,14 +43,16 @@ func NewCollector(program string) prometheus.Collector {
4143 Namespace : program ,
4244 Name : "build_info" ,
4345 Help : fmt .Sprintf (
44- "A metric with a constant '1' value labeled by version, revision, branch, and goversion from which %s was built." ,
46+ "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 ." ,
4547 program ,
4648 ),
4749 ConstLabels : prometheus.Labels {
4850 "version" : Version ,
4951 "revision" : getRevision (),
5052 "branch" : Branch ,
5153 "goversion" : GoVersion ,
54+ "goos" : GoOS ,
55+ "goarch" : GoArch ,
5256 },
5357 },
5458 func () float64 { return 1 },
@@ -74,7 +78,7 @@ func Print(program string) string {
7478 "buildUser" : BuildUser ,
7579 "buildDate" : BuildDate ,
7680 "goVersion" : GoVersion ,
77- "platform" : runtime . GOOS + "/" + runtime . GOARCH ,
81+ "platform" : GoOS + "/" + GoArch ,
7882 }
7983 t := template .Must (template .New ("version" ).Parse (versionInfoTmpl ))
8084
@@ -90,7 +94,7 @@ func Info() string {
9094 return fmt .Sprintf ("(version=%s, branch=%s, revision=%s)" , Version , Branch , getRevision ())
9195}
9296
93- // BuildContext returns goVersion, buildUser and buildDate information.
97+ // BuildContext returns goVersion, platform, buildUser and buildDate information.
9498func BuildContext () string {
95- return fmt .Sprintf ("(go=%s, user=%s, date=%s)" , GoVersion , BuildUser , BuildDate )
99+ return fmt .Sprintf ("(go=%s, platform=%s, user=%s, date=%s)" , GoVersion , GoOS + "/" + GoArch , BuildUser , BuildDate )
96100}
0 commit comments