Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72f32bffd1 | ||
| 17593e466c | |||
|
|
6f996f3cc4 |
@@ -1,5 +1,5 @@
|
|||||||
# VictoriaMetrics
|
# VictoriaMetrics
|
||||||

|

|
||||||
|
|
||||||
Wrappers are a form of middleware that can be used with go-micro services. They can wrap both the Client and Server handlers.
|
Wrappers are a form of middleware that can be used with go-micro services. They can wrap both the Client and Server handlers.
|
||||||
This plugin implements the HandlerWrapper interface to provide automatic prometheus metric handling
|
This plugin implements the HandlerWrapper interface to provide automatic prometheus metric handling
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -6,7 +6,7 @@ toolchain go1.24.4
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/VictoriaMetrics/metrics v1.40.2
|
github.com/VictoriaMetrics/metrics v1.40.2
|
||||||
go.unistack.org/micro/v4 v4.1.22
|
go.unistack.org/micro/v4 v4.1.23
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
|||||||
4
go.sum
4
go.sum
@@ -30,8 +30,8 @@ github.com/valyala/histogram v1.2.0 h1:wyYGAZZt3CpwUiIb9AU/Zbllg1llXyrtApRS815OL
|
|||||||
github.com/valyala/histogram v1.2.0/go.mod h1:Hb4kBwb4UxsaNbbbh+RRz8ZR6pdodR57tzWUS3BUzXY=
|
github.com/valyala/histogram v1.2.0/go.mod h1:Hb4kBwb4UxsaNbbbh+RRz8ZR6pdodR57tzWUS3BUzXY=
|
||||||
go.unistack.org/micro-proto/v4 v4.1.0 h1:qPwL2n/oqh9RE3RTTDgt28XK3QzV597VugQPaw9lKUk=
|
go.unistack.org/micro-proto/v4 v4.1.0 h1:qPwL2n/oqh9RE3RTTDgt28XK3QzV597VugQPaw9lKUk=
|
||||||
go.unistack.org/micro-proto/v4 v4.1.0/go.mod h1:ArmK7o+uFvxSY3dbJhKBBX4Pm1rhWdLEFf3LxBrMtec=
|
go.unistack.org/micro-proto/v4 v4.1.0/go.mod h1:ArmK7o+uFvxSY3dbJhKBBX4Pm1rhWdLEFf3LxBrMtec=
|
||||||
go.unistack.org/micro/v4 v4.1.22 h1:CBRwTxj53gtFkQKyzUeoIad9LyyJaMCJDcsmzUwXHdI=
|
go.unistack.org/micro/v4 v4.1.23 h1:T9O1O1mN60JHqIAIw+XkNik8xb0h90O9fJ55uQMb8VU=
|
||||||
go.unistack.org/micro/v4 v4.1.22/go.mod h1:nlBXTbx0rQrSZX4HPp2m57PHmpuGPWUd0O+jpUIiPto=
|
go.unistack.org/micro/v4 v4.1.23/go.mod h1:nlBXTbx0rQrSZX4HPp2m57PHmpuGPWUd0O+jpUIiPto=
|
||||||
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
|
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
|
||||||
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
|
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
|
||||||
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
|
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
|
||||||
|
|||||||
@@ -69,7 +69,14 @@ func (r *victoriametricsMeter) Gauge(name string, f func() float64, labels ...st
|
|||||||
|
|
||||||
func (r *victoriametricsMeter) Histogram(name string, labels ...string) meter.Histogram {
|
func (r *victoriametricsMeter) Histogram(name string, labels ...string) meter.Histogram {
|
||||||
if r.prometheusCompat {
|
if r.prometheusCompat {
|
||||||
return r.set.GetOrCreatePrometheusHistogram(r.buildName(name, labels...))
|
return r.set.GetOrCreatePrometheusHistogramExt(r.buildName(name, labels...), r.opts.Quantiles)
|
||||||
|
}
|
||||||
|
return r.set.GetOrCreateHistogram(r.buildName(name, labels...))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *victoriametricsMeter) HistogramExt(name string, quantiles []float64, labels ...string) meter.Histogram {
|
||||||
|
if r.prometheusCompat {
|
||||||
|
return r.set.GetOrCreatePrometheusHistogramExt(r.buildName(name, labels...), quantiles)
|
||||||
}
|
}
|
||||||
return r.set.GetOrCreateHistogram(r.buildName(name, labels...))
|
return r.set.GetOrCreateHistogram(r.buildName(name, labels...))
|
||||||
}
|
}
|
||||||
@@ -98,6 +105,9 @@ func (r *victoriametricsMeter) Init(opts ...meter.Option) error {
|
|||||||
if v, ok := r.opts.Context.Value(prometheusCompatKey{}).(bool); ok && v {
|
if v, ok := r.opts.Context.Value(prometheusCompatKey{}).(bool); ok && v {
|
||||||
r.prometheusCompat = v
|
r.prometheusCompat = v
|
||||||
}
|
}
|
||||||
|
if r.opts.Quantiles == nil {
|
||||||
|
r.opts.Quantiles = meter.DefaultQuantiles
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user