gitlab.com/gitlab-org/labkit@v1.21.0/monitoring/build_info_gauge.go (about)

     1  package monitoring
     2  
     3  import "github.com/prometheus/client_golang/prometheus"
     4  
     5  const (
     6  	// GitlabBuildInfoGaugeMetricName is the name of the label containing
     7  	// build information for this process.
     8  	GitlabBuildInfoGaugeMetricName = "gitlab_build_info"
     9  
    10  	buildInfoVersionLabel       = "version"
    11  	buildInfoBuildTimeLabel     = "built"
    12  	buildInfoModifiedLabel      = "modified"
    13  	buildInfoCommittedLabel     = "committed"
    14  	buildInfoGoVersionLabel     = "go_version"
    15  	buildInfoModulePathLabel    = "module_path"
    16  	buildInfoModuleVersionLabel = "module_version"
    17  )
    18  
    19  // registerBuildInfoGauge registers a label with the current server version
    20  // making it easy to see what versions of the application are running across a cluster.
    21  func registerBuildInfoGauge(registerer prometheus.Registerer, labels prometheus.Labels) {
    22  	gitlabBuildInfoGauge := prometheus.NewGauge(prometheus.GaugeOpts{
    23  		Name:        GitlabBuildInfoGaugeMetricName,
    24  		Help:        "Current build info for this GitLab Service",
    25  		ConstLabels: labels,
    26  	})
    27  	registerer.MustRegister(gitlabBuildInfoGauge)
    28  	gitlabBuildInfoGauge.Set(1)
    29  }