Skip to content
Permalink
Browse files

Rework mutex protection of the PathMap

  • Loading branch information...
matthewmcneely committed Nov 20, 2018
1 parent 65cd873 commit c62ce0670960312e27919d3c81e998df7427cd6d
Showing with 4 additions and 2 deletions.
  1. +4 −2 prom.go
@@ -95,11 +95,11 @@ func New(options ...func(*Prometheus)) *Prometheus {
}

func (p *Prometheus) update() {
p.PathMap.Lock()
p.Ignored.RLock()
if p.PathMap.values == nil {
p.PathMap.values = make(map[string]string)
}
p.PathMap.Lock()
p.Ignored.RLock()
defer func() {
p.PathMap.Unlock()
p.Ignored.RUnlock()
@@ -164,7 +164,9 @@ func (p *Prometheus) register() {
// single handler
func (p *Prometheus) Instrument() gin.HandlerFunc {
return func(c *gin.Context) {
p.PathMap.RLock()
if p.PathMap.values == nil {
p.PathMap.RUnlock()
p.update()
}
var path string

0 comments on commit c62ce06

Please sign in to comment.
You can’t perform that action at this time.