feat(api/health): report commit

pull/18173/head
Pavel Zavora 2020-05-26 14:02:38 +02:00
parent 634d83577c
commit c35c90aa68
3 changed files with 6 additions and 1 deletions

View File

@ -9,7 +9,7 @@ import (
// HealthHandler returns the status of the process.
func HealthHandler(w http.ResponseWriter, r *http.Request) {
msg := fmt.Sprintf(`{"name":"influxdb", "message":"ready for queries and writes", "status":"pass", "checks":[], "version": %q}`, platform.GetBuildInfo().Version)
msg := fmt.Sprintf(`{"name":"influxdb", "message":"ready for queries and writes", "status":"pass", "checks":[], "version": %q, "commit": %q}`, platform.GetBuildInfo().Version, platform.GetBuildInfo().Commit)
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(http.StatusOK)
fmt.Fprintln(w, msg)

View File

@ -64,6 +64,9 @@ func TestHealthHandler(t *testing.T) {
if _, found := content["version"]; !found {
t.Errorf("%q. HealthHandler() no version reported", tt.name)
}
if _, found := content["commit"]; !found {
t.Errorf("%q. HealthHandler() no commit reported", tt.name)
}
})
}
}

View File

@ -10895,6 +10895,8 @@ components:
- fail
version:
type: string
commit:
type: string
Labels:
type: array
items: