Debian Codegraph @

prometheus/collectors/collectors.go

raw
1 // Copyright 2021 The Prometheus Authors
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13
14 // Package collectors provides implementations of prometheus.Collector to
15 // conveniently collect process and Go-related metrics.
16 package collectors
17
18 import "github.com/prometheus/client_golang/prometheus"
19
20 // NewBuildInfoCollector returns a collector collecting a single metric
21 // "go_build_info" with the constant value 1 and three labels "path", "version",
22 // and "checksum". Their label values contain the main module path, version, and
23 // checksum, respectively. The labels will only have meaningful values if the
24 // binary is built with Go module support and from source code retrieved from
25 // the source repository (rather than the local file system). This is usually
26 // accomplished by building from outside of GOPATH, specifying the full address
27 // of the main package, e.g. "GO111MODULE=on go run
28 // github.com/prometheus/client_golang/examples/random". If built without Go
29 // module support, all label values will be "unknown". If built with Go module
30 // support but using the source code from the local file system, the "path" will
31 // be set appropriately, but "checksum" will be empty and "version" will be
32 // "(devel)".
33 //
34 // This collector uses only the build information for the main module. See
35 // https://github.com/povilasv/prommod for an example of a collector for the
36 // module dependencies.
37 func NewBuildInfoCollector() prometheus.Collector {
38 //nolint:staticcheck // Ignore SA1019 until v2.
39 return prometheus.NewBuildInfoCollector()
40 }