It's a small Go package exposing running app informations. It's inspired by go-actuator
NB: I was forced to expose the same information for a Go microservice :D
go get github.com/josuebrunel/tellme
import "github.com/josuebrunel/tellme"
// These variables are expected to be set by the LDFLAGS arguments
// LDFLAGS would be set at compile time by the CI/CD pipeline of any code
// which leverages this library
var (
EnvName string // Environment name
AppName string // Application/Service name
AppVersion string // Application/Service version
CommitAuthor string // CommitAuthor - The username/email of the person who authored the commit
CommitID string // CommitID - The SHA1 checksum of the commit
CommitTime string // CommitTime - The time that the commit occurred
BuildTime string // BuildTime - Timestamp that the build occurred
Branch string // Branch - The branch the commit exists in
)
// Initialize your app
app := tellme.NewApp(
EnvName,
AppName,
AppVersion,
BuildTime,
CommitAuthor,
CommitID,
CommitTime,
Branch,
)
// Get Info
app.GetInfo() // returns a json serializable struct
// Get Env
app.GetEnv() // returns map[string]string
// Get Metrics
app.GetMetrics() // returns a json serializable struct
// Get Threaddump
app.GetThreadDump() // returns []byte
NAME=myApp
VERSION=$(shell git describe)
BUILDTIME=$(shell date --rfc-3339=ns)
COMMIT_AUTHOR=$(shell git show -s --format='%ae')
COMMIT_ID=$(shell git show -s --format='%H')
COMMIT_TIME=$(shell git show -s --format=%ci)
BRANCH=$(shell git branch --show)
build:
go build -ldflags="-X 'app/<subpkg>.AppName=${NAME}' -X 'app/<subpkg>.AppVersion=${VERSION}' -X 'app/<subpkg>.BuildTime=${BUILDTIME}' -X 'app/<subpkg>.CommitAuthor=${COMMIT_AUTHOR}' -X 'app/<subpkg>.CommitID=${COMMIT_ID}' -X 'app/<subpkg>.CommitTime=${COMMIT_TIME}' -X 'app/<subpkg>.Branch=${BRANCH}'"\
-o bin/$(NAME) ${ENTRYPOINT}