Skip to content

Commit 107e6b8

Browse files
authored
fix: missing metrics with Caddy 2.9 (#1007)
1 parent 6c2d07d commit 107e6b8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

caddy/mercure.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile"
2121
"github.com/caddyserver/caddy/v2/modules/caddyhttp"
2222
"github.com/dunglas/mercure"
23-
"github.com/prometheus/client_golang/prometheus"
2423
"go.uber.org/zap"
2524
"go.uber.org/zap/zapcore"
2625
)
@@ -29,7 +28,6 @@ const defaultHubURL = "/.well-known/mercure"
2928

3029
var (
3130
ErrCompatibility = errors.New("compatibility mode only supports protocol version 7")
32-
metrics = mercure.NewPrometheusMetrics(prometheus.DefaultRegisterer) //nolint:gochecknoglobals
3331

3432
// Deprecated: use transports Caddy modules.
3533
transports = caddy.NewUsagePool() //nolint:gochecknoglobals
@@ -189,6 +187,8 @@ func createTransportLegacy(m *Mercure) (mercure.Transport, error) {
189187

190188
//nolint:wrapcheck
191189
func (m *Mercure) Provision(ctx caddy.Context) error { //nolint:funlen,gocognit
190+
metrics := mercure.NewPrometheusMetrics(ctx.GetMetricsRegistry())
191+
192192
if err := m.populateJWTConfig(); err != nil {
193193
return err
194194
}

0 commit comments

Comments
 (0)