mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 11:11:30 -04:00
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:
parent
eff73c3016
commit
83ef0b6f6d
5 changed files with 418 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue