aboutsummaryrefslogtreecommitdiff
path: root/metric.go
blob: 7e3e8b20c16efdf8577a4d8d2e4796b6644b73a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package stfe

import (
	"github.com/google/trillian/monitoring"
	"github.com/google/trillian/monitoring/prometheus"
)

var (
	reqcnt           monitoring.Counter   // number of incoming http requests
	rspcnt           monitoring.Counter   // number of valid http responses
	latency          monitoring.Histogram // request-response latency
	lastSthTimestamp monitoring.Gauge     // unix timestamp from the most recent sth
	lastSthSize      monitoring.Gauge     // tree size of most recent sth
)

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")
	latency = mf.NewHistogram("http_latency", "http request-response latency", "logid", "endpoint", "status")
	lastSthTimestamp = mf.NewGauge("last_sth_timestamp", "unix timestamp while handling the most recent sth", "logid")
	lastSthSize = mf.NewGauge("last_sth_size", "most recent sth tree size", "logid")
}