micro-meter-victoriametrics/victoriametrics_test.go
Vasiliy Tolstov 4fef299e78
Some checks failed
codeql / analyze (go) (push) Failing after 45s
build / test (push) Failing after 4m52s
build / lint (push) Successful in 9m31s
add ability to use prometheus compat histogram
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2024-11-09 19:49:45 +03:00

30 lines
642 B
Go

package victoriametrics
import (
"bytes"
"testing"
)
func TestBuildName(t *testing.T) {
m := NewMeter()
im := m.(*victoriametricsMeter)
check := `micro_foo{micro_aaa="b",micro_bar="baz",micro_ccc="d"}`
name := im.buildName("micro_foo", "micro_bar", "baz", "micro_aaa", "b", "micro_ccc", "d")
if name != check {
t.Fatalf("metric name error: %s != %s", name, check)
}
cnt := m.Counter("counter", "key", "val")
cnt.Inc()
}
func TestPrometheusCompat(t *testing.T) {
m := NewMeter(PrometheusCompat(true))
m.Histogram("foo", "key", "val").Update(15)
buf := bytes.NewBuffer(nil)
_ = m.Write(buf)
t.Logf("\n%s", buf.Bytes())
}