(lbls labels.Labels, value float64, operation string, updateIfAlreadyExist bool)
| 67 | } |
| 68 | |
| 69 | func (g *gauge) updateSeries(lbls labels.Labels, value float64, operation string, updateIfAlreadyExist bool) { |
| 70 | hash := lbls.Hash() |
| 71 | |
| 72 | g.seriesMtx.RLock() |
| 73 | s, ok := g.series[hash] |
| 74 | g.seriesMtx.RUnlock() |
| 75 | |
| 76 | g.seriesDemand.Insert(hash) |
| 77 | |
| 78 | if ok { |
| 79 | // target_info will always be 1 so if the series exists, we don't need to go through this loop |
| 80 | if !updateIfAlreadyExist { |
| 81 | return |
| 82 | } |
| 83 | g.updateSeriesValue(hash, s, value, operation) |
| 84 | return |
| 85 | } |
| 86 | |
| 87 | g.seriesMtx.Lock() |
| 88 | defer g.seriesMtx.Unlock() |
| 89 | |
| 90 | s, lbls, hash = resolveSeries(g.series, hash, lbls, g.lifecycler, 1) |
| 91 | if s != nil { |
| 92 | if !updateIfAlreadyExist { |
| 93 | return |
| 94 | } |
| 95 | g.updateSeriesValue(hash, s, value, operation) |
| 96 | return |
| 97 | } |
| 98 | |
| 99 | g.series[hash] = g.newSeries(lbls, value) |
| 100 | } |
| 101 | |
| 102 | func (g *gauge) newSeries(lbls labels.Labels, value float64) *gaugeSeries { |
| 103 | return &gaugeSeries{ |
no test coverage detected