wrapper/monitoring/prometheus: use default registry (#532)
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
16b5bac080
commit
53940dda18
@ -60,17 +60,15 @@ func NewHandlerWrapper(opts ...server.Option) server.HandlerWrapper {
|
||||
[]string{"method"},
|
||||
)
|
||||
|
||||
reg := prometheus.NewRegistry()
|
||||
wrapreg := prometheus.WrapRegistererWith(md, reg)
|
||||
wrapreg := prometheus.WrapRegistererWith(md, prometheus.DefaultRegisterer)
|
||||
wrapreg.MustRegister(
|
||||
prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{}),
|
||||
prometheus.NewGoCollector(),
|
||||
//prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{}),
|
||||
//prometheus.NewGoCollector(),
|
||||
opsCounter,
|
||||
timeCounterSummary,
|
||||
timeCounterHistogram,
|
||||
)
|
||||
|
||||
prometheus.DefaultGatherer = reg
|
||||
prometheus.DefaultRegisterer = wrapreg
|
||||
|
||||
return func(fn server.HandlerFunc) server.HandlerFunc {
|
||||
|
@ -5,6 +5,8 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/micro/go-micro/v2/broker"
|
||||
bmemory "github.com/micro/go-micro/v2/broker/memory"
|
||||
"github.com/micro/go-micro/v2/client"
|
||||
"github.com/micro/go-micro/v2/client/selector"
|
||||
"github.com/micro/go-micro/v2/registry/memory"
|
||||
@ -34,8 +36,9 @@ func (t *testHandler) Method(ctx context.Context, req *TestRequest, rsp *TestRes
|
||||
|
||||
func TestPrometheusMetrics(t *testing.T) {
|
||||
// setup
|
||||
registry := memory.NewRegistry()
|
||||
sel := selector.NewSelector(selector.Registry(registry))
|
||||
reg := memory.NewRegistry()
|
||||
brk := bmemory.NewBroker(broker.Registry(reg))
|
||||
sel := selector.NewSelector(selector.Registry(reg))
|
||||
|
||||
name := "test"
|
||||
id := "id-1234567890"
|
||||
@ -50,7 +53,8 @@ func TestPrometheusMetrics(t *testing.T) {
|
||||
server.Name(name),
|
||||
server.Version(version),
|
||||
server.Id(id),
|
||||
server.Registry(registry),
|
||||
server.Registry(reg),
|
||||
server.Broker(brk),
|
||||
server.WrapHandler(
|
||||
NewHandlerWrapper(
|
||||
server.Metadata(md),
|
||||
|
Loading…
x
Reference in New Issue
Block a user