Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/grafana-agent
Path: blob/main/pkg/build/build.go
4094 views
1
package build
2
3
import (
4
"github.com/prometheus/client_golang/prometheus"
5
"github.com/prometheus/common/version"
6
)
7
8
// Version information passed to Prometheus version package.
9
// Package path as used by linker changes based on vendoring being used or not,
10
// so it's easier just to use stable Agent path, and pass it to
11
// Prometheus in the code.
12
var (
13
Version string
14
Revision string
15
Branch string
16
BuildUser string
17
BuildDate string
18
)
19
20
func init() {
21
injectVersion()
22
}
23
24
func injectVersion() {
25
version.Version = Version
26
version.Revision = Revision
27
version.Branch = Branch
28
version.BuildUser = BuildUser
29
version.BuildDate = BuildDate
30
}
31
32
// NewCollector returns a collector that exports metrics about current
33
// version information.
34
func NewCollector(program string) prometheus.Collector {
35
injectVersion()
36
37
return version.NewCollector(program)
38
}
39
40
// Print returns version information.
41
func Print(program string) string {
42
injectVersion()
43
44
return version.Print(program)
45
}
46
47