From 998b68425f2c5e09ac37d864dfc3ead2b7163e09 Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Tue, 10 Nov 2020 19:52:32 +0100 Subject: replaced sync.Once with init() --- instance.go | 1 - metric.go | 5 +---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/instance.go b/instance.go index baff329..7a353fe 100644 --- a/instance.go +++ b/instance.go @@ -56,7 +56,6 @@ func NewInstance(lp *LogParameters, client trillian.TrillianLogClient, deadline Deadline: deadline, } i.registerHandlers(mux) - once.Do(metricSetup) return i, nil } diff --git a/metric.go b/metric.go index 7179458..1d0f100 100644 --- a/metric.go +++ b/metric.go @@ -1,14 +1,11 @@ package stfe import ( - "sync" - "github.com/google/trillian/monitoring" "github.com/google/trillian/monitoring/prometheus" ) var ( - once sync.Once reqcnt monitoring.Counter // number of incoming http requests rspcnt monitoring.Counter // number of valid http responses latency monitoring.Histogram // request-response latency @@ -17,7 +14,7 @@ var ( lastSthSize monitoring.Gauge // tree size of most recent sth ) -func metricSetup() { +func init() { mf := prometheus.MetricFactory{} reqcnt = mf.NewCounter("http_req", "number of http requests", "logid", "endpoint") rspcnt = mf.NewCounter("http_rsp", "number of http requests", "logid", "endpoint", "status") -- cgit v1.2.3