mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-12 12:46:23 +01:00
Move rowsAddedTotal counter to Storage (#6841)
### Describe Your Changes Reduced the scope of rowsAddedTotal variable from global to Storage. This metric clearly belongs to a given Storage object as it counts the number of records added by a given Storage instance. Reducing the scope improves the incapsulation and allows to reset this variable during the unit tests (i.e. every time a new Storage object is created by a test, that object gets a new variable). Signed-off-by: Artem Fetishev <wwctrsrx@gmail.com>
This commit is contained in:
parent
6db4682d95
commit
332d290b38
@ -40,6 +40,8 @@ const (
|
||||
|
||||
// Storage represents TSDB storage.
|
||||
type Storage struct {
|
||||
rowsAddedTotal atomic.Uint64
|
||||
|
||||
tooSmallTimestampRows atomic.Uint64
|
||||
tooBigTimestampRows atomic.Uint64
|
||||
|
||||
@ -567,7 +569,7 @@ func (m *Metrics) Reset() {
|
||||
|
||||
// UpdateMetrics updates m with metrics from s.
|
||||
func (s *Storage) UpdateMetrics(m *Metrics) {
|
||||
m.RowsAddedTotal = rowsAddedTotal.Load()
|
||||
m.RowsAddedTotal += s.rowsAddedTotal.Load()
|
||||
m.DedupsDuringMerge = dedupsDuringMerge.Load()
|
||||
m.SnapshotsCount += uint64(s.mustGetSnapshotsCount())
|
||||
|
||||
@ -1714,8 +1716,6 @@ func (s *Storage) ForceMergePartitions(partitionNamePrefix string) error {
|
||||
return s.tb.ForceMergePartitions(partitionNamePrefix)
|
||||
}
|
||||
|
||||
var rowsAddedTotal atomic.Uint64
|
||||
|
||||
// AddRows adds the given mrs to s.
|
||||
//
|
||||
// The caller should limit the number of concurrent AddRows calls to the number
|
||||
@ -1737,7 +1737,7 @@ func (s *Storage) AddRows(mrs []MetricRow, precisionBits uint8) {
|
||||
mrs = nil
|
||||
}
|
||||
s.add(ic.rrs, ic.tmpMrs, mrsBlock, precisionBits)
|
||||
rowsAddedTotal.Add(uint64(len(mrsBlock)))
|
||||
s.rowsAddedTotal.Add(uint64(len(mrsBlock)))
|
||||
}
|
||||
putMetricRowsInsertCtx(ic)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user