File: build_info_gauge.go

package info (click to toggle)
golang-gitlab-gitlab-org-labkit 1.17.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,092 kB
  • sloc: sh: 210; javascript: 49; makefile: 4
file content (29 lines) | stat: -rw-r--r-- 1,090 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package monitoring

import "github.com/prometheus/client_golang/prometheus"

const (
	// GitlabBuildInfoGaugeMetricName is the name of the label containing
	// build information for this process.
	GitlabBuildInfoGaugeMetricName = "gitlab_build_info"

	buildInfoVersionLabel       = "version"
	buildInfoBuildTimeLabel     = "built"
	buildInfoModifiedLabel      = "modified"
	buildInfoCommittedLabel     = "committed"
	buildInfoGoVersionLabel     = "go_version"
	buildInfoModulePathLabel    = "module_path"
	buildInfoModuleVersionLabel = "module_version"
)

// registerBuildInfoGauge registers a label with the current server version
// making it easy to see what versions of the application are running across a cluster.
func registerBuildInfoGauge(registerer prometheus.Registerer, labels prometheus.Labels) {
	gitlabBuildInfoGauge := prometheus.NewGauge(prometheus.GaugeOpts{
		Name:        GitlabBuildInfoGaugeMetricName,
		Help:        "Current build info for this GitLab Service",
		ConstLabels: labels,
	})
	registerer.MustRegister(gitlabBuildInfoGauge)
	gitlabBuildInfoGauge.Set(1)
}