Skip to content

Do not use prometheusx to include git commit in software #144

@SaiedKazemi

Description

@SaiedKazemi

Many of M-Lab's Dockerfiles have a line like the following to include the git commit of the repo in the software they build:

RUN go get -v -ldflags "-X github.com/m-lab/go/prometheusx.GitShortCommit=$(git log -1 --format=%h)"  .

This has the undesired side-effect of pulling in the prometheusx package for software that has nothing to do with Prometheus. Moreover, creating an application that uses any package that includes prometheusx results in polluting the flags when printing its help message. Below is an example:

$ cat main.go
package main

import (
	"flag"
	"fmt"
	"github.com/m-lab/traceroute-caller/parser"
)

var someFlag = flag.Bool("f", false, "Some flag")

func main() {
	flag.Parse()
	fmt.Printf("%+v\n", parser.Scamper1{})
}
$ go build -o main .
$ ./main -h
Usage of ./main:
  -f	Some flag
  -prometheusx.listen-address string
    	 (default ":9990")
$

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions