Commit 0f68bba9 authored by Ben Wilson's avatar Ben Wilson

op-exporter version metric

parent a21cec6d
SHELL := /bin/bash
VERSION := `git describe --abbrev=0`
ifndef VERSION
VERSION := `jq .version package.json `
endif
ifndef GITCOMMIT
GITCOMMIT := `git rev-parse HEAD`
endif
ifndef BUILDDATE
BUILDDATE := `date +%Y-%m-%d`
BUILDUSER := `whoami`
endif
LDFLAGSSTRING :=-X github.com/ethereum-optimism/optimism/go/op_exporter/version.Version=$(VERSION)
LDFLAGSSTRING +=-X github.com/ethereum-optimism/optimism/go/op_exporter/version.GitCommit=$(GITCOMMIT)
LDFLAGSSTRING +=-X github.com/ethereum-optimism/optimism/go/op_exporter/version.BuildDate=$(BUILDDATE)
LDFLAGSSTRING +=-X github.com/ethereum-optimism/optimism/go/op_exporter/version.BuildUser=$(BUILDUSER)
LDFLAGS :=-ldflags "$(LDFLAGSSTRING)"
......
......@@ -24,6 +24,12 @@ var (
Help: "Is the sequencer healthy?"},
[]string{"network"},
)
opExporterVersion = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "op_exporter_version",
Help: "Verion of the op-exporter software"},
[]string{"version", "commit", "goVersion", "buildDate"},
)
)
func init() {
......@@ -31,4 +37,6 @@ func init() {
prometheus.MustRegister(gasPrice)
prometheus.MustRegister(blockNumber)
prometheus.MustRegister(healthySequencer)
prometheus.MustRegister(opExporterVersion)
}
......@@ -6,6 +6,7 @@ import (
"io/ioutil"
"net/http"
"os"
"strings"
"sync"
"time"
......@@ -50,7 +51,7 @@ var (
enableK8sQuery = kingpin.Flag(
"k8s.enable",
"Enable kubernetes info lookup.",
).Default("true").Bool()
).Default("false").Bool()
)
type healthCheck struct {
......@@ -81,7 +82,8 @@ func main() {
log.Infoln("exporter config", *listenAddress, *rpcProvider, *networkLabel)
log.Infoln("Starting op_exporter", version.Info())
log.Infoln("Build context", version.BuildContext())
opExporterVersion.WithLabelValues(
strings.Trim(version.Version, "\""), version.GitCommit, version.GoVersion, version.BuildDate).Inc()
health := healthCheck{
mu: new(sync.RWMutex),
height: 0,
......
......@@ -8,7 +8,6 @@ import (
var (
Version string
GitCommit string
BuildUser string
BuildDate string
GoVersion = runtime.Version()
)
......@@ -18,5 +17,5 @@ func Info() string {
}
func BuildContext() string {
return fmt.Sprintf("(go=%s, user=%s, date=%s)", GoVersion, BuildUser, BuildDate)
return fmt.Sprintf("(go=%s, date=%s)", GoVersion, BuildDate)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment