go-spatial / tegola

Tegola is a Mapbox Vector Tile server written in Go
http://tegola.io/
MIT License
1.28k stars 195 forks source link

Crashes when observer is enabled (prometheus metrics) #907

Closed edulog87 closed 3 months ago

edulog87 commented 1 year ago

Hi, I'm using Tegola v0.16.0 (and tested with v0.15.x)

I want to enable metrics for Prometheus following documentation (https://pkg.go.dev/github.com/go-spatial/tegola/observability/prometheus#section-readme)

[observer]
type = "prometheus"

When I start tegola it crashes and I get the following error:

panic: duplicate metrics collector registration attempted

goroutine 1 [running]:
github.com/prometheus/client_golang/prometheus.(*Registry).MustRegister(0x0?, {0xc000419d40?, 0x3, 0x0?})
    /go/src/github.com/go-spatial/tegola/vendor/github.com/prometheus/client_golang/prometheus/registry.go:403 +0x7f
github.com/go-spatial/tegola/observability/prometheus.(*observer).MustRegister(0xc00004fce0?, {0xc000419d40?, 0x0?, 0x0?})
    /go/src/github.com/go-spatial/tegola/observability/prometheus/prometheus.go:160 +0x27
github.com/go-spatial/tegola/atlas.(*Atlas).SetObservability(0x1b46680, {0x14d8de0, 0xc00043a500})
    /go/src/github.com/go-spatial/tegola/atlas/atlas.go:269 +0x3a9
github.com/go-spatial/tegola/atlas.SetObservability(...)
    /go/src/github.com/go-spatial/tegola/atlas/atlas.go:337
github.com/go-spatial/tegola/cmd/tegola/cmd.initConfig({0x7ffdbdc55bf1, 0x12}, 0x0, {0xfe09d3, 0x4}, {0xfe5a48?, 0x4?})
    /go/src/github.com/go-spatial/tegola/cmd/tegola/cmd/root.go:152 +0x6b7
github.com/go-spatial/tegola/cmd/tegola/cmd.rootCmdValidatePersistent(0x1ad95e0?, {0xfe0d7f?, 0x2?, 0x2?})
    /go/src/github.com/go-spatial/tegola/cmd/tegola/cmd/root.go:92 +0x169
github.com/go-spatial/cobra.(*Command).execute(0x1ad95e0, {0xc0000c9d00, 0x2, 0x2})
    /go/src/github.com/go-spatial/tegola/vendor/github.com/go-spatial/cobra/command.go:741 +0x58b
github.com/go-spatial/cobra.(*Command).ExecuteC(0x1ad9380)
    /go/src/github.com/go-spatial/tegola/vendor/github.com/go-spatial/cobra/command.go:852 +0x2e5
github.com/go-spatial/cobra.(*Command).Execute(0x46a87b?)
    /go/src/github.com/go-spatial/tegola/vendor/github.com/go-spatial/cobra/command.go:800 +0x19
main.main()
    /go/src/github.com/go-spatial/tegola/cmd/tegola/main.go:13 +0x25

I only declared once that block. There is a bug or I'm missing some thing ?

thanks

iwpnd commented 1 year ago

Hey there 👋

please also share you configuration, otherwise I suspect it to be a duplicate of #886 that is being worked on at #903.

quick fix, either dont use prometheus if you have a multiple map/multi provider setup, or create separate deployments for each.

ARolek commented 3 months ago

I'm going to close this issue as a fix for a related panic happened awhile ago in https://github.com/go-spatial/tegola/pull/915. If the issue persists please re-open.