Skip to content

Commit 555822f

Browse files
include version info
Signed-off-by: Ricky Moorhouse <[email protected]>
1 parent e4f2e86 commit 555822f

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN GOVERSION=$(egrep "^toolchain " go.mod | awk -Fgo '{print $2}') && \
1313

1414
RUN go mod download
1515

16-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./out/trawler .
16+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./out/trawler -ldflags="-X 'main.Version=$(git describe --tags)' -X 'main.BuildTime=$(date +%Y%m%dT%H%M)'" .
1717
RUN dnf install ca-certificates --assumeyes
1818
RUN groupadd -r app && useradd -r -g app app
1919

exporter.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ import (
2525
)
2626

2727
var (
28-
promCounter = promauto.NewCounterVec(
29-
prometheus.CounterOpts{
30-
Name: "myapp_processed_ops_total",
31-
Help: "The total number of processed events",
28+
promInfo = promauto.NewGaugeVec(
29+
prometheus.GaugeOpts{
30+
Name: "trawler_version_info",
31+
Help: "Trawler version and build info",
3232
},
33-
[]string{"collector"})
33+
[]string{"version", "buildTime"})
34+
Version = "development"
35+
BuildTime = ""
3436
)
3537

3638
var log = alog.UseChannel("trawler")
@@ -129,6 +131,7 @@ func main() {
129131
log.Log(alog.WARNING, "Error loading logging config from flags: ", err.Error())
130132
}
131133

134+
promInfo.WithLabelValues(Version, BuildTime).Set(1)
132135
// Initialise appropriate nets...
133136
if config.Nets.APIConnect.Enabled {
134137
a := apiconnect.APIConnect{}

0 commit comments

Comments
 (0)