featurebase/prometheus/prometheus_test.go
pokeeffe-molecula a1fc6d04a1 introduce performance counters and system table fanout, plus refactor metrics (#2363)
* performance counters

* first cut of perf counters and system table fanout and a wire protocol
* significantly refactored prometheus support; removed statsd and exprvar

* removed node_id

* put dax subquery test back

* Change Translator.TranslateFieldIDs method to take a dax.TableKeyer

There are a bunch of other calls to the Translator interface methods
with currently take an `index string`, and those need to be converted to
dax.TableKeyer as well. But I need to review each call, because in at
least one place I noticed one being called with `result.Index` instead
of with the qtbl available. And I don't yet know how those could be
different.

Co-authored-by: Travis Turner <travis@molecula.com>
(cherry picked from commit 7f6ea0e6e5)
2023-01-19 21:35:02 +00:00

42 lines
1.1 KiB
Go

// Copyright 2022 Molecula Corp. (DBA FeatureBase).
// SPDX-License-Identifier: Apache-2.0
package prometheus_test
import (
"testing"
pilosaPrometheus "github.com/featurebasedb/featurebase/v3/prometheus"
"github.com/prometheus/client_golang/prometheus"
io_prometheus_client "github.com/prometheus/client_model/go"
)
func TestPrometheusClient_Methods(t *testing.T) {
c := test.MustRunCluster(t, 1)
defer c.Close()
metricFams, err := prometheus.DefaultGatherer.Gather()
if err != nil {
t.Fatal(err)
}
for _, metricName := range []string{
"pilosa_sql_statistics_sql_bulk_insert_batches_sec",
"pilosa_sql_statistics_sql_bulk_inserts_sec",
"pilosa_sql_statistics_sql_deletes_sec",
"pilosa_sql_statistics_sql_inserts_sec",
"pilosa_sql_statistics_sql_requests_sec",
} {
if metricExists(metricName, metricFams) {
continue
}
t.Fatalf("metric does not exist: %s", metricName)
}
}
func metricExists(metricName string, metricFams []*io_prometheus_client.MetricFamily) bool {
for _, metricFam := range metricFams {
if metricFam.GetName() == metricName {
return true
}
}
return false
}