(lbls labels.Labels, value float64)
| 59 | } |
| 60 | |
| 61 | func (c *counter) Inc(lbls labels.Labels, value float64) { |
| 62 | if value < 0 { |
| 63 | panic("counter can only increase") |
| 64 | } |
| 65 | |
| 66 | hash := lbls.Hash() |
| 67 | |
| 68 | c.seriesMtx.RLock() |
| 69 | s, ok := c.series[hash] |
| 70 | c.seriesMtx.RUnlock() |
| 71 | |
| 72 | c.seriesDemand.Insert(hash) |
| 73 | if ok { |
| 74 | c.updateSeries(hash, s, value) |
| 75 | return |
| 76 | } |
| 77 | |
| 78 | c.seriesMtx.Lock() |
| 79 | defer c.seriesMtx.Unlock() |
| 80 | |
| 81 | s, lbls, hash = resolveSeries(c.series, hash, lbls, c.lifecycler, 1) |
| 82 | if s != nil { |
| 83 | c.updateSeries(hash, s, value) |
| 84 | return |
| 85 | } |
| 86 | |
| 87 | c.series[hash] = c.newSeries(lbls, value) |
| 88 | } |
| 89 | |
| 90 | func resolveSeries[T any](series map[uint64]*T, hash uint64, lbls labels.Labels, lifecycler Limiter, count uint32) (*T, labels.Labels, uint64) { |
| 91 | // If we already track the series, return it. |
nothing calls this directly
no test coverage detected