Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using labels causes Prometheus sink to panic #78

Open
dougfort opened this issue May 25, 2018 · 0 comments
Open

Using labels causes Prometheus sink to panic #78

dougfort opened this issue May 25, 2018 · 0 comments

Comments

@dougfort
Copy link

Note this in prometheus.go

func (p *PrometheusSink) SetGaugeWithLabels(parts []string, val float32, labels []metrics.Label) {
        p.mu.Lock()
        defer p.mu.Unlock()
        key, hash := p.flattenKey(parts, labels)
        g, ok := p.gauges[hash]
        if !ok {
                g = prometheus.NewGauge(prometheus.GaugeOpts{
                        Name:        key,
                        Help:        key,
                        ConstLabels: prometheusLabels(labels),
                })
                prometheus.MustRegister(g)
                p.gauges[key] = g
        }
        g.Set(float64(val))
}

it checks p.gauges[hash] and stores p.gauges[key] = g

storehttpserver_1  | 2018-05-25T12:13:51Z |DEBU| labels = [{name value}] service=store-http-server
storehttpserver_1  | panic: duplicate metrics collector registration attempted
storehttpserver_1  |
storehttpserver_1  | goroutine 13 [running]:
storehttpserver_1  | github.com/prometheus/client_golang/prometheus.(*Registry).MustRegister(0xc42005e6c0, 0xc42029c7a0, 0x1, 0x1)
storehttpserver_1  | 	/Users/dougfort/go/src/github.com/prometheus/client_golang/prometheus/registry.go:362 +0x9e
storehttpserver_1  | github.com/prometheus/client_golang/prometheus.MustRegister(0xc42029c7a0, 0x1, 0x1)
storehttpserver_1  | 	/Users/dougfort/go/src/github.com/prometheus/client_golang/prometheus/registry.go:154 +0x53
storehttpserver_1  | github.com/armon/go-metrics/prometheus.(*PrometheusSink).IncrCounterWithLabels(0xc420184f60, 0xc42029c740, 0x1, 0x1, 0x0, 0xc420277a00, 0x1, 0x1)
storehttpserver_1  | 	/Users/dougfort/go/src/github.com/armon/go-metrics/prometheus/prometheus.go:117 +0x2b6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant