MCPcopy
hub / github.com/grafana/tempo / Inc

Method Inc

modules/generator/registry/counter.go:61–88  ·  view source on GitHub ↗
(lbls labels.Labels, value float64)

Source from the content-addressed store, hash-verified

59}
60
61func (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
90func 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.

Callers

nothing calls this directly

Calls 5

updateSeriesMethod · 0.95
newSeriesMethod · 0.95
resolveSeriesFunction · 0.85
HashMethod · 0.80
InsertMethod · 0.80

Tested by

no test coverage detected