NewCollector returns a collector that exports metrics about current version information.
(program string)
| 24 | // NewCollector returns a collector that exports metrics about current version |
| 25 | // information. |
| 26 | func NewCollector(program string) prometheus.Collector { |
| 27 | return prometheus.NewGaugeFunc( |
| 28 | prometheus.GaugeOpts{ |
| 29 | Namespace: program, |
| 30 | Name: "build_info", |
| 31 | Help: fmt.Sprintf( |
| 32 | "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.", |
| 33 | program, |
| 34 | ), |
| 35 | ConstLabels: prometheus.Labels{ |
| 36 | "version": version.Version, |
| 37 | "revision": version.GetRevision(), |
| 38 | "branch": version.Branch, |
| 39 | "goversion": version.GoVersion, |
| 40 | "goos": version.GoOS, |
| 41 | "goarch": version.GoArch, |
| 42 | "tags": version.GetTags(), |
| 43 | }, |
| 44 | }, |
| 45 | func() float64 { return 1 }, |
| 46 | ) |
| 47 | } |