From 7ec4d58392f1d45b95fa3c30fccf2d584e1c10cf Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 10 May 2021 10:54:38 -0400 Subject: [PATCH] cleanup / fix tests --- internal/server/metrics.go | 11 ++++++----- tests/107/main.go | 2 +- tests/mock_test.go | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/internal/server/metrics.go b/internal/server/metrics.go index a3164a5a..5cf03585 100644 --- a/internal/server/metrics.go +++ b/internal/server/metrics.go @@ -15,7 +15,7 @@ var ( these metrics are taken from basicStats() / extStats() by accessing the map and directly exporting the value found */ - "num_collections": prometheus.NewDesc("tile38_collections_total", "Total number of collections", nil, nil), + "num_collections": prometheus.NewDesc("tile38_collections", "Total number of collections", nil, nil), "pid": prometheus.NewDesc("tile38_pid", "", nil, nil), "aof_size": prometheus.NewDesc("tile38_aof_size_bytes", "", nil, nil), "num_hooks": prometheus.NewDesc("tile38_hooks_total", "", nil, nil), @@ -57,9 +57,7 @@ func (s *Server) MetricsHandler(w http.ResponseWriter, r *http.Request) { s, ) - h := promhttp.HandlerFor(reg, promhttp.HandlerOpts{}) - - h.ServeHTTP(w, r) + promhttp.HandlerFor(reg, promhttp.HandlerOpts{}).ServeHTTP(w, r) } func (s *Server) Describe(ch chan<- *prometheus.Desc) { @@ -69,6 +67,9 @@ func (s *Server) Describe(ch chan<- *prometheus.Desc) { } func (s *Server) Collect(ch chan<- prometheus.Metric) { + s.mu.RLock() + defer s.mu.RUnlock() + m := make(map[string]interface{}) s.basicStats(m) s.extStats(m) @@ -87,7 +88,7 @@ func (s *Server) Collect(ch chan<- prometheus.Metric) { ) /* - add stats per collection + add objects/points/strings stats for each collection */ s.cols.Ascend(nil, func(v interface{}) bool { c := v.(*collectionKeyContainer) diff --git a/tests/107/main.go b/tests/107/main.go index 2a0d5f20..23df4ce1 100644 --- a/tests/107/main.go +++ b/tests/107/main.go @@ -100,7 +100,7 @@ func main() { func startTile38Server() { log.Println("start tile38 server") - err := server.Serve("localhost", tile38Port, "data", false) + err := server.Serve("localhost", tile38Port, "data", false, "") if err != nil { log.Fatal(err) } diff --git a/tests/mock_test.go b/tests/mock_test.go index 77825e87..3af8fa51 100644 --- a/tests/mock_test.go +++ b/tests/mock_test.go @@ -52,7 +52,7 @@ func mockOpenServer() (*mockServer, error) { s := &mockServer{port: port} tlog.SetOutput(logOutput) go func() { - if err := server.Serve("localhost", port, dir, true); err != nil { + if err := server.Serve("localhost", port, dir, true, ""); err != nil { log.Fatal(err) } }()