diff --git a/.circleci/config.yml b/.circleci/config.yml index 8825486..ca490b3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,7 +33,7 @@ jobs: command: make go-build-for-docker - run: mkdir ./circle-artifacts && cp ./o-neko-catnip ./circle-artifacts/ - save_cache: - key: oneko-catnip-artifacts-{{ .Environment.CIRCLE_SHA1 }} + key: oneko-catnip-artifacts-{{ or .Environment.CIRCLE_TAG .Environment.CIRCLE_SHA1 }} paths: - ./circle-artifacts/ - store_artifacts: @@ -46,7 +46,7 @@ jobs: - checkout - setup_remote_docker - restore_cache: - key: oneko-catnip-artifacts-{{ .Environment.CIRCLE_SHA1 }} + key: oneko-catnip-artifacts-{{ or .Environment.CIRCLE_TAG .Environment.CIRCLE_SHA1 }} - run: cp ./circle-artifacts/o-neko-catnip . - run: docker build -t subshellgmbh/o-neko-catnip:latest-dev . - run: echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin @@ -59,7 +59,7 @@ jobs: - checkout - setup_remote_docker - restore_cache: - key: oneko-catnip-artifacts-{{ .Environment.CIRCLE_SHA1 }} + key: oneko-catnip-artifacts-{{ or .Environment.CIRCLE_TAG .Environment.CIRCLE_SHA1 }} - run: cp ./circle-artifacts/o-neko-catnip . - run: docker build -t subshellgmbh/o-neko-catnip:latest . - run: docker tag subshellgmbh/o-neko-catnip:latest subshellgmbh/o-neko-catnip:$CIRCLE_TAG diff --git a/go.mk b/go.mk index cb2dfa2..5db8a60 100644 --- a/go.mk +++ b/go.mk @@ -2,7 +2,7 @@ GO ?= go LINTER ?= golangci-lint GO_TESTSUM ?= gotestsum GIT_DIRTY := $(shell git diff --quiet || echo '-dirty') -VERSION := $(shell [ -z $(git tag --points-at HEAD) ] || echo $(git tag --points-at HEAD)) +VERSION := $(shell [ -z $$(git tag --points-at HEAD) ] && echo "unknown" || echo $$(git tag --points-at HEAD)) COMMIT := $(shell git rev-parse --short HEAD)$(GIT_DIRTY) LDFLAGS += -ldflags '-extldflags "-static" -s -w -X=main.GitTag=$(VERSION) -X=main.GitCommit=$(COMMIT)' # -s -w reduces binary size by removing some debug information BUILDFLAGS += -installsuffix cgo --tags release diff --git a/pkg/o-neko-catnip/metrics/metrics.go b/pkg/o-neko-catnip/metrics/metrics.go index 451d684..ea4846d 100644 --- a/pkg/o-neko-catnip/metrics/metrics.go +++ b/pkg/o-neko-catnip/metrics/metrics.go @@ -23,7 +23,7 @@ func RegisterCommonMetrics(appVersion string) { func startMonitoringUptime() { startTime := time.Now() promauto.NewGaugeFunc(prometheus.GaugeOpts{ - Name: "oneko_url_trigger_uptime_duration_seconds", + Name: "oneko_catnip_uptime_duration_seconds", Help: "The uptime of the application", }, func() float64 { return time.Since(startTime).Seconds() @@ -32,7 +32,7 @@ func startMonitoringUptime() { func registerAppInfoMetric(appVersion string) { promauto.NewGauge(prometheus.GaugeOpts{ - Name: "oneko_url_trigger_info", + Name: "oneko_catnip_info", Help: "Information about this application", ConstLabels: map[string]string{ "version": appVersion, diff --git a/pkg/o-neko-catnip/oneko/helpers.go b/pkg/o-neko-catnip/oneko/helpers.go index 8f30793..5dbc911 100644 --- a/pkg/o-neko-catnip/oneko/helpers.go +++ b/pkg/o-neko-catnip/oneko/helpers.go @@ -32,12 +32,12 @@ func buildClient(conf *config.Config) (*resty.Client, error) { func startPingMonitor(api *ONekoApi, ctx context.Context) { onekoPingDuration := promauto.NewHistogram(prometheus.HistogramOpts{ - Name: "oneko_url_trigger_api_ping_duration_seconds", + Name: "oneko_catnip_api_ping_duration_seconds", Help: "Ping duration to the O-Neko base application.", Buckets: prometheus.DefBuckets, }) onekoConnected := promauto.NewGauge(prometheus.GaugeOpts{ - Name: "oneko_url_trigger_api_connected", + Name: "oneko_catnip_api_connected", Help: "1 if the API is connected, 0 if not", }) onekoConnected.Set(0) diff --git a/pkg/o-neko-catnip/oneko/oneko.go b/pkg/o-neko-catnip/oneko/oneko.go index 52a33d1..acfb857 100644 --- a/pkg/o-neko-catnip/oneko/oneko.go +++ b/pkg/o-neko-catnip/oneko/oneko.go @@ -37,28 +37,28 @@ func New(configuration *config.Config, ctx context.Context) *ONekoApi { log: logger.New("oneko"), cache: requestCache, wakeupCounter: promauto.NewCounter(prometheus.CounterOpts{ - Name: "oneko_url_trigger_wakeups_total", + Name: "oneko_catnip_wakeups_total", Help: "The number of wakeup API requests done.", ConstLabels: map[string]string{ "success": "true", }, }), errorCounter: promauto.NewCounter(prometheus.CounterOpts{ - Name: "oneko_url_trigger_wakeups_total", + Name: "oneko_catnip_wakeups_total", Help: "The number of wakeup API requests done.", ConstLabels: map[string]string{ "success": "false", }, }), apiCallDuration: promauto.NewHistogram(prometheus.HistogramOpts{ - Name: "oneko_url_trigger_api_call_duration_seconds", + Name: "oneko_catnip_api_call_duration_seconds", Help: "Wakeup API call duration.", Buckets: prometheus.DefBuckets, }), } promauto.NewGaugeFunc(prometheus.GaugeOpts{ - Name: "oneko_url_trigger_cache_size", + Name: "oneko_catnip_cache_size", Help: "The number of cached API responses", }, func() float64 { return float64(len(requestCache.GetKeys()))