Page MenuHomePhabricator

Add/report build meta data
Closed, ResolvedPublic

Description

It would be helpful if Kask reported build meta data, at a minimum, the Git tag/hash, a version, and the build date. This information should be at least logged on startup, but perhaps it makes sense to also include this in the /healthz response as well.

See also: https://www.robustperception.io/exposing-the-software-version-to-prometheus (exporting version via Prometheus)

Event Timeline

Eevans triaged this task as Normal priority.Jul 1 2019, 12:48 PM
Eevans created this task.
Eevans updated the task description. (Show Details)Jul 1 2019, 12:50 PM
Eevans updated the task description. (Show Details)Jul 1 2019, 4:39 PM

Change 520260 had a related patch set uploaded (by Eevans; owner: Eevans):
[mediawiki/services/kask@master] Report build meta data

https://gerrit.wikimedia.org/r/520260

Eevans added a comment.Jul 2 2019, 3:33 PM
log output
eevans@hermes:~/dev/src/git/go-kask(versioning)$ devscripts/docker_run ./kask --config config.yaml.test | aeson-pretty 
{
    "time": "2019-07-02T15:29:15Z",
    "appname": "kask",
    "msg": "Initializing Kask 1.0.0 (Git: v1.0.0-3-gc2dcf59, Go version: go1.7.4, Build host: aea19cb0dd4c, Timestamp: 2019-07-02T15:25:51+00:00)...",
    "level": "INFO"
}
{
    "time": "2019-07-02T15:29:15Z",
    "appname": "kask",
    "msg": "Starting service as http://172.17.0.3:8080/v1/",
    "level": "INFO"
}
metrics
eevans@hermes:~/dev/src/git/go-kask(versioning)$ curl -D - -X GET http://172.17.0.3:8080/metrics
HTTP/1.1 200 OK
Content-Length: 5268
Content-Type: text/plain; version=0.0.4
Date: Tue, 02 Jul 2019 15:30:31 GMT

[ ... ]

# HELP kask_build_information Build information
# TYPE kask_build_information gauge
kask_build_information{build_date="2019-07-02T15:25:51+00:00",build_host="aea19cb0dd4c",git="v1.0.0-3-gc2dcf59",go_version="go1.7.4",version="1.0.0"} 1

[ ... ]
/healthz response
eevans@hermes:~/dev/src/git/go-kask(versioning)$ curl -D - -X GET http://172.17.0.3:8080/healthz
HTTP/1.1 200 OK
Content-Type: application/json
Date: Tue, 02 Jul 2019 15:32:01 GMT
Content-Length: 158

{
  "version": "1.0.0",
  "git": "v1.0.0-3-gc2dcf59",
  "build_data": "2019-07-02T15:25:51+00:00",
  "build_host": "aea19cb0dd4c",
  "go_version": "go1.7.4"
}
Eevans added a comment.Jul 2 2019, 3:34 PM
build output
eevans@hermes:~/dev/src/git/go-kask(versioning)$ devscripts/docker_run make clean test functional-test
rm -f kask
GOPATH=/usr/share/gocode go build -ldflags "-X main.version=1.0.0 -X main.gitTag=v1.0.0-3-gab83187 -X main.buildDate=2019-07-02T15:33:29+00:00 -X main.buildHost=e0cdaa8cc607" kask.go config.go http.go logging.go storage.go

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
VERSION ......: 1.0.0
GIT TAG ......: v1.0.0-3-gab83187
BUILD HOST ...: e0cdaa8cc607
BUILD DATE ...: 2019-07-02T15:33:29+00:00
GO VERSION ...: go1.7.4
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GOPATH=/usr/share/gocode go test  -tags=unit
PASS
ok  	_/app	0.006s
golint -set_exit_status ./...
go vet ./...
GOPATH=/usr/share/gocode go test  -tags=functional -config config.yaml.test
PASS
ok  	_/app	5.031s

Change 520260 merged by jenkins-bot:
[mediawiki/services/kask@master] Report build meta data

https://gerrit.wikimedia.org/r/520260

Change 520302 had a related patch set uploaded (by Eevans; owner: Eevans):
[mediawiki/services/kask@master] rename kask_build_information -> kask_build_info

https://gerrit.wikimedia.org/r/520302

Change 520302 merged by jenkins-bot:
[mediawiki/services/kask@master] rename kask_build_information -> kask_build_info

https://gerrit.wikimedia.org/r/520302

Change 520342 had a related patch set uploaded (by Eevans; owner: Eevans):
[mediawiki/services/kask@master] Treat Git tag as the canonical version

https://gerrit.wikimedia.org/r/520342

Change 520342 merged by jenkins-bot:
[mediawiki/services/kask@master] Treat Git tag as the canonical version

https://gerrit.wikimedia.org/r/520342

Eevans closed this task as Resolved.EditedJul 3 2019, 9:47 PM

This is now complete, and Kask v1.0.0 has been released.