Skip to content

Commit 7ec53a6

Browse files
committed
update
1 parent f3ae38a commit 7ec53a6

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

middleware.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
// Config responsible to configure middleware
1313
type Config struct {
14+
Skipper echo.Skipper
1415
Namespace string
1516
Buckets []float64
1617
Subsystem string
@@ -25,6 +26,9 @@ const (
2526

2627
// DefaultConfig has the default instrumentation config
2728
var DefaultConfig = Config{
29+
Skipper: func(c echo.Context) bool {
30+
return c.Request().URL().Path() == `/metrics`
31+
},
2832
Namespace: "echo",
2933
Subsystem: "http",
3034
Buckets: []float64{
@@ -94,8 +98,16 @@ func MetricsMiddlewareWithConfig(config Config) echo.MiddlewareFuncd {
9498
Buckets: config.Buckets,
9599
}, []string{"method", "handler"})
96100

101+
skipper := config.Skipper
102+
if skipper == nil {
103+
skipper = echo.DefaultSkipper
104+
}
105+
97106
return func(next echo.Handler) echo.HandlerFunc {
98107
return func(c echo.Context) error {
108+
if skipper(c) {
109+
return next.Handle(c)
110+
}
99111
req := c.Request()
100112
path := c.Path()
101113

prometheus/prometheus.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ scrape_configs:
2525
# honor_labels: true
2626
# static_configs:
2727
# - targets: ["pushgateway:9091"]
28+
# basic_auth:
29+
# username: username
30+
# password: your-password
2831

2932
- job_name: "webx"
3033
scrape_interval: 5s

0 commit comments

Comments
 (0)