Export snowflake broker metrics for prometheus

This change adds a prometheus exporter for our existing snowflake broker
metrics. Current values for the metrics can be fetched by sending a GET
request to /prometheus.
This commit is contained in:
Cecylia Bocovich 2021-03-30 15:40:02 -04:00
parent eff73c3016
commit 83ef0b6f6d
5 changed files with 418 additions and 2 deletions

View file

@ -9,6 +9,7 @@ import (
"net/http"
"net/http/httptest"
"os"
"sync"
"testing"
"time"
@ -21,8 +22,12 @@ func NullLogger() *log.Logger {
return logger
}
var promOnce sync.Once
func TestBroker(t *testing.T) {
promOnce.Do(InitPrometheus)
Convey("Context", t, func() {
ctx := NewBrokerContext(NullLogger())
@ -298,6 +303,8 @@ func TestBroker(t *testing.T) {
}
func TestSnowflakeHeap(t *testing.T) {
promOnce.Do(InitPrometheus)
Convey("SnowflakeHeap", t, func() {
h := new(SnowflakeHeap)
heap.Init(h)
@ -341,6 +348,8 @@ func TestSnowflakeHeap(t *testing.T) {
}
func TestGeoip(t *testing.T) {
promOnce.Do(InitPrometheus)
Convey("Geoip", t, func() {
tv4 := new(GeoIPv4Table)
err := GeoIPLoadFile(tv4, "test_geoip")
@ -445,6 +454,7 @@ func TestGeoip(t *testing.T) {
}
func TestMetrics(t *testing.T) {
promOnce.Do(InitPrometheus)
Convey("Test metrics...", t, func() {
done := make(chan bool)