Skip to content

Commit 33bc169

Browse files
committed
rename metrics and set units according to https://prometheus.io/docs/practices/naming/
1 parent 2c59949 commit 33bc169

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

internal/scti/handlers.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -68,45 +68,45 @@ var (
6868
lastSCTTimestamp *prometheus.GaugeVec // origin => value
6969
reqsCounter *prometheus.CounterVec // origin, op => value
7070
rspsCounter *prometheus.CounterVec // origin, op, code => value
71-
rspLatency *prometheus.HistogramVec // origin, op, code => value
71+
rspDuration *prometheus.HistogramVec // origin, op, code => value
7272
)
7373

7474
// setupMetrics initializes all the exported metrics.
7575
func setupMetrics() {
7676
// TODO(phboneff): add metrics for deduplication and chain storage.
7777
knownLogs = promauto.NewGaugeVec(
7878
prometheus.GaugeOpts{
79-
Name: "ct_known_logs",
79+
Name: "ct_known_logs_info",
8080
Help: "Set to 1 for known logs",
8181
},
8282
[]string{"origin"})
8383
lastSCTTimestamp = promauto.NewGaugeVec(
8484
prometheus.GaugeOpts{
85-
Name: "ct_last_sct_timestamp_ms",
86-
Help: "Time of last SCT in ms since epoch",
85+
Name: "ct_sct_last_timestamp_seconds",
86+
Help: "Time of last SCT in seconds since epoch",
8787
},
8888
[]string{"origin"})
8989
lastSCTIndex = promauto.NewGaugeVec(
9090
prometheus.GaugeOpts{
91-
Name: "ct_last_sct_index",
91+
Name: "ct_sct_last_index",
9292
Help: "Index of last SCT",
9393
},
9494
[]string{"origin"})
9595
reqsCounter = promauto.NewCounterVec(
9696
prometheus.CounterOpts{
97-
Name: "ct_http_reqs",
97+
Name: "ct_http_requests_total",
9898
Help: "Number of requests",
9999
},
100100
[]string{"origin", "ep"})
101101
rspsCounter = promauto.NewCounterVec(
102102
prometheus.CounterOpts{
103-
Name: "ct_http_rsps",
103+
Name: "ct_http_responses_total",
104104
Help: "Number of responses",
105105
},
106106
[]string{"origin", "op", "code"})
107-
rspLatency = promauto.NewHistogramVec(
107+
rspDuration = promauto.NewHistogramVec(
108108
prometheus.HistogramOpts{
109-
Name: "ct_http_latency",
109+
Name: "ct_http_request_duration_seconds",
110110
Help: "Latency of responses in seconds",
111111
},
112112
[]string{"origin", "op", "code"})
@@ -140,7 +140,7 @@ func (a appHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
140140
a.opts.RequestLog.origin(logCtx, a.log.origin)
141141
defer func() {
142142
latency := a.opts.TimeSource.Now().Sub(startTime).Seconds()
143-
rspLatency.WithLabelValues(label0, label1, strconv.Itoa(statusCode)).Observe(latency)
143+
rspDuration.WithLabelValues(label0, label1, strconv.Itoa(statusCode)).Observe(latency)
144144
}()
145145
klog.V(2).Infof("%s: request %v %q => %s", a.log.origin, r.Method, r.URL, a.name)
146146
// TODO(phboneff): add a.Method directly on the handler path and remove this test.
@@ -352,7 +352,7 @@ func addChainInternal(ctx context.Context, opts *HandlerOptions, log *log, w htt
352352
}
353353
klog.V(3).Infof("%s: %s <= SCT", log.origin, method)
354354
if sct.Timestamp == timeMillis {
355-
lastSCTTimestamp.WithLabelValues(log.origin).Set(float64(sct.Timestamp))
355+
lastSCTTimestamp.WithLabelValues(log.origin).Set(float64(sct.Timestamp) / 1000)
356356
lastSCTIndex.WithLabelValues(log.origin).Set(float64(idx))
357357
}
358358

0 commit comments

Comments
 (0)