update micro
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
c187502cd4
commit
a239f86139
14
go.mod
14
go.mod
@ -1,8 +1,16 @@
|
||||
module go.unistack.org/micro-meter-victoriametrics/v3
|
||||
|
||||
go 1.16
|
||||
go 1.22
|
||||
|
||||
toolchain go1.23.2
|
||||
|
||||
require (
|
||||
github.com/VictoriaMetrics/metrics v1.23.1
|
||||
go.unistack.org/micro/v3 v3.10.19
|
||||
github.com/VictoriaMetrics/metrics v1.35.1
|
||||
go.unistack.org/micro/v3 v3.10.100
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/valyala/fastrand v1.1.0 // indirect
|
||||
github.com/valyala/histogram v1.2.0 // indirect
|
||||
golang.org/x/sys v0.27.0 // indirect
|
||||
)
|
||||
|
15
go.sum
15
go.sum
@ -1,13 +1,10 @@
|
||||
github.com/VictoriaMetrics/metrics v1.23.1 h1:/j8DzeJBxSpL2qSIdqnRFLvQQhbJyJbbEi22yMm7oL0=
|
||||
github.com/VictoriaMetrics/metrics v1.23.1/go.mod h1:rAr/llLpEnAdTehiNlUxKgnjcOuROSzpw0GvjpEbvFc=
|
||||
github.com/imdario/mergo v0.3.14/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
|
||||
github.com/silas/dag v0.0.0-20211117232152-9d50aa809f35/go.mod h1:7RTUFBdIRC9nZ7/3RyRNH1bdqIShrDejd1YbLwgPS+I=
|
||||
github.com/VictoriaMetrics/metrics v1.35.1 h1:o84wtBKQbzLdDy14XeskkCZih6anG+veZ1SwJHFGwrU=
|
||||
github.com/VictoriaMetrics/metrics v1.35.1/go.mod h1:r7hveu6xMdUACXvB8TYdAj8WEsKzWB0EkpJN+RDtOf8=
|
||||
github.com/valyala/fastrand v1.1.0 h1:f+5HkLW4rsgzdNoleUOB69hyT9IlD2ZQh9GyDMfb5G8=
|
||||
github.com/valyala/fastrand v1.1.0/go.mod h1:HWqCzkrkg6QXT8V2EXWvXCoow7vLwOFN002oeRzjapQ=
|
||||
github.com/valyala/histogram v1.2.0 h1:wyYGAZZt3CpwUiIb9AU/Zbllg1llXyrtApRS815OLoQ=
|
||||
github.com/valyala/histogram v1.2.0/go.mod h1:Hb4kBwb4UxsaNbbbh+RRz8ZR6pdodR57tzWUS3BUzXY=
|
||||
go.unistack.org/micro/v3 v3.10.19 h1:JtPacglETxHyb+GiuMdfxqGtnWSTYXPQm6PlDQfNIl8=
|
||||
go.unistack.org/micro/v3 v3.10.19/go.mod h1:XIArw29f0b3uvF4cq96X/nQt2f0J2OGnjh8J+DBbC0s=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
go.unistack.org/micro/v3 v3.10.100 h1:yWOaU0ImCGm5k5MUzlIobJUOr+KLfrR/BoDZvcHyKxM=
|
||||
go.unistack.org/micro/v3 v3.10.100/go.mod h1:YzMldzHN9Ei+zy5t/Psu7RUWDZwUfrNYiStSQtTz90g=
|
||||
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
|
||||
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
|
@ -30,10 +30,6 @@ func (r *victoriametricsMeter) Clone(opts ...meter.Option) meter.Meter {
|
||||
}
|
||||
|
||||
func (r *victoriametricsMeter) buildName(name string, labels ...string) string {
|
||||
if len(r.opts.MetricPrefix) > 0 {
|
||||
name = r.opts.MetricPrefix + name
|
||||
}
|
||||
|
||||
nl := len(r.opts.Labels) + len(labels)
|
||||
if nl == 0 {
|
||||
return name
|
||||
@ -43,14 +39,6 @@ func (r *victoriametricsMeter) buildName(name string, labels ...string) string {
|
||||
nlabels = append(nlabels, r.opts.Labels...)
|
||||
nlabels = append(nlabels, labels...)
|
||||
|
||||
if len(r.opts.LabelPrefix) == 0 {
|
||||
return meter.BuildName(name, nlabels...)
|
||||
}
|
||||
|
||||
for idx := 0; idx < nl; idx++ {
|
||||
nlabels[idx] = r.opts.LabelPrefix + nlabels[idx]
|
||||
idx++
|
||||
}
|
||||
return meter.BuildName(name, nlabels...)
|
||||
}
|
||||
|
||||
|
@ -1,21 +1,14 @@
|
||||
package victoriametrics
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"go.unistack.org/micro/v3/client"
|
||||
"go.unistack.org/micro/v3/codec"
|
||||
"go.unistack.org/micro/v3/meter"
|
||||
"go.unistack.org/micro/v3/meter/wrapper"
|
||||
)
|
||||
|
||||
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("foo", "bar", "baz", "aaa", "b", "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)
|
||||
}
|
||||
@ -23,30 +16,3 @@ func TestBuildName(t *testing.T) {
|
||||
cnt := m.Counter("counter", "key", "val")
|
||||
cnt.Inc()
|
||||
}
|
||||
|
||||
func TestWrapper(t *testing.T) {
|
||||
m := NewMeter() // meter.Labels("test_key", "test_val"))
|
||||
|
||||
w := wrapper.NewClientWrapper(
|
||||
wrapper.ServiceName("svc1"),
|
||||
wrapper.ServiceVersion("0.0.1"),
|
||||
wrapper.ServiceID("12345"),
|
||||
wrapper.Meter(m),
|
||||
)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
c := client.NewClient(client.Wrap(w))
|
||||
if err := c.Init(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
rsp := &codec.Frame{}
|
||||
req := &codec.Frame{}
|
||||
err := c.Call(ctx, c.NewRequest("svc2", "Service.Method", req), rsp)
|
||||
_, _ = rsp, err
|
||||
buf := bytes.NewBuffer(nil)
|
||||
_ = m.Write(buf, meter.WriteProcessMetrics(false), meter.WriteFDMetrics(false))
|
||||
if !bytes.Contains(buf.Bytes(), []byte(`micro_client_request_inflight{micro_endpoint="svc2.Service.Method"} 0`)) {
|
||||
t.Fatalf("invalid metrics output: %s", buf.Bytes())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user