|
5 | 5 | "strconv"
|
6 | 6 |
|
7 | 7 | "github.com/prometheus/client_golang/prometheus"
|
8 |
| - "github.com/prometheus/client_golang/prometheus/promauto" |
9 | 8 | "github.com/webx-top/echo"
|
10 | 9 | )
|
11 | 10 |
|
@@ -82,21 +81,24 @@ func MetricsMiddleware() echo.MiddlewareFuncd {
|
82 | 81 |
|
83 | 82 | // MetricsMiddlewareWithConfig returns an echo middleware for instrumentation.
|
84 | 83 | func MetricsMiddlewareWithConfig(config Config) echo.MiddlewareFuncd {
|
85 |
| - |
86 |
| - httpRequests := promauto.NewCounterVec(prometheus.CounterOpts{ |
| 84 | + httpRequests := prometheus.NewCounterVec(prometheus.CounterOpts{ |
87 | 85 | Namespace: config.Namespace,
|
88 | 86 | Subsystem: config.Subsystem,
|
89 | 87 | Name: httpRequestsCount,
|
90 | 88 | Help: "Number of HTTP operations",
|
91 | 89 | }, []string{"status", "method", "handler"})
|
| 90 | + prometheus.DefaultRegisterer.Unregister(httpRequests) |
| 91 | + prometheus.DefaultRegisterer.MustRegister(httpRequests) |
92 | 92 |
|
93 |
| - httpDuration := promauto.NewHistogramVec(prometheus.HistogramOpts{ |
| 93 | + httpDuration := prometheus.NewHistogramVec(prometheus.HistogramOpts{ |
94 | 94 | Namespace: config.Namespace,
|
95 | 95 | Subsystem: config.Subsystem,
|
96 | 96 | Name: httpRequestsDuration,
|
97 | 97 | Help: "Spend time by processing a route",
|
98 | 98 | Buckets: config.Buckets,
|
99 | 99 | }, []string{"method", "handler"})
|
| 100 | + prometheus.DefaultRegisterer.Unregister(httpDuration) |
| 101 | + prometheus.DefaultRegisterer.MustRegister(httpDuration) |
100 | 102 |
|
101 | 103 | skipper := config.Skipper
|
102 | 104 | if skipper == nil {
|
|
0 commit comments