@@ -24,6 +24,7 @@ import (
2424
2525 "github.com/prometheus/common/promslog"
2626 promslogflag "github.com/prometheus/common/promslog/flag"
27+ "github.com/prometheus/common/version"
2728 "github.com/urfave/cli/v2"
2829 "golang.org/x/sync/semaphore"
2930
@@ -48,8 +49,6 @@ Version: %s
4849 htmlPprof = `<p><a href="/debug/pprof">Pprof</a><p>`
4950)
5051
51- var version = "custom-build"
52-
5352var sem = semaphore .NewWeighted (1 )
5453
5554const (
@@ -90,7 +89,7 @@ func main() {
9089func NewYACEApp () * cli.App {
9190 yace := cli .NewApp ()
9291 yace .Name = "Yet Another CloudWatch Exporter"
93- yace .Version = version
92+ yace .Version = version . Version
9493 yace .Usage = "YACE configured to retrieve CloudWatch metrics through the AWS API"
9594 yace .Description = ""
9695 yace .Authors = []* cli.Author {
@@ -219,7 +218,7 @@ func NewYACEApp() *cli.App {
219218 & cli.StringFlag {Name : "config.file" , Value : "config.yml" , Usage : "Path to configuration file." , Destination : & configFile },
220219 },
221220 Action : func (_ * cli.Context ) error {
222- logger = newLogger (logFormat , logLevel ).With ("version" , version )
221+ logger = newLogger (logFormat , logLevel ).With ("version" , version . Version )
223222 logger .Info ("Parsing config" )
224223 cfg := config.ScrapeConf {}
225224 if _ , err := cfg .Load (configFile , logger ); err != nil {
@@ -236,7 +235,7 @@ func NewYACEApp() *cli.App {
236235 Aliases : []string {"v" },
237236 Usage : "prints current yace version." ,
238237 Action : func (_ * cli.Context ) error {
239- fmt .Println (version )
238+ fmt .Println (version . Version )
240239 os .Exit (0 )
241240 return nil
242241 },
@@ -249,7 +248,7 @@ func NewYACEApp() *cli.App {
249248}
250249
251250func startScraper (c * cli.Context ) error {
252- logger = newLogger (logFormat , logLevel ).With ("version" , version )
251+ logger = newLogger (logFormat , logLevel ).With ("version" , version . Version )
253252
254253 // log warning if the two concurrency limiting methods are configured via CLI
255254 if c .IsSet ("cloudwatch-concurrency" ) && c .IsSet ("cloudwatch-concurrency.per-api-limit-enabled" ) {
@@ -299,7 +298,7 @@ func startScraper(c *cli.Context) error {
299298 pprofLink = htmlPprof
300299 }
301300
302- _ , _ = w .Write ([]byte (fmt .Sprintf (htmlVersion , version , pprofLink )))
301+ _ , _ = w .Write ([]byte (fmt .Sprintf (htmlVersion , version . Version , pprofLink )))
303302 })
304303
305304 mux .HandleFunc ("/healthz" , func (w http.ResponseWriter , _ * http.Request ) {
@@ -341,7 +340,7 @@ func startScraper(c *cli.Context) error {
341340 go s .decoupled (ctx , logger , newJobsCfg , cache )
342341 })
343342
344- logger .Info ("Yace startup completed" , "version" , version , "feature_flags" , strings .Join (featureFlags , "," ))
343+ logger .Info ("Yace startup completed" , "build_info" , version . Info (), "build_context" , version . BuildContext () , "feature_flags" , strings .Join (featureFlags , "," ))
345344
346345 srv := & http.Server {Addr : addr , Handler : mux }
347346 return srv .ListenAndServe ()
0 commit comments