Skip to content

Commit

Permalink
Fix Tempo build-info (#295)
Browse files Browse the repository at this point in the history
* Add missing build-info

Signed-off-by: Daniel González Lopes <danielgonzalezlopes@gmail.com>

* Use image-tag instead of version file

Signed-off-by: Daniel González Lopes <danielgonzalezlopes@gmail.com>
  • Loading branch information
dgzlopes committed Oct 30, 2020
1 parent 2ee9738 commit 5d8d2f6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Makefile
@@ -1,3 +1,9 @@
# Version number
VERSION=$(shell ./tools/image-tag | cut -d, -f 1)

GIT_REVISION := $(shell git rev-parse --short HEAD)
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)

GOPATH := $(shell go env GOPATH)
GORELEASER := $(GOPATH)/bin/goreleaser

Expand All @@ -14,7 +20,7 @@ ALL_DOC := $(shell find . \( -name "*.md" -o -name "*.yaml" \) \
# ALL_PKGS is used with 'go cover'
ALL_PKGS := $(shell go list $(sort $(dir $(ALL_SRC))))

GO_OPT= -mod vendor
GO_OPT= -mod vendor -ldflags "-X main.Branch=$(GIT_BRANCH) -X main.Revision=$(GIT_REVISION) -X main.Version=$(VERSION)"
GOTEST_OPT?= -race -timeout 5m -count=1
GOTEST_OPT_WITH_COVERAGE = $(GOTEST_OPT) -cover
GOTEST=go test
Expand Down
10 changes: 10 additions & 0 deletions cmd/tempo/main.go
Expand Up @@ -25,7 +25,17 @@ import (

const appName = "tempo"

// Version is set via build flag -ldflags -X main.Version
var (
Version string
Branch string
Revision string
)

func init() {
version.Version = Version
version.Branch = Branch
version.Revision = Revision
prometheus.MustRegister(version.NewCollector(appName))
}

Expand Down

0 comments on commit 5d8d2f6

Please sign in to comment.