mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00: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
6f17ee0d0f
commit
30f98916f9
1 changed files with 4 additions and 4 deletions
|
@ -40,6 +40,8 @@ const (
|
|||
|
||||
// Storage represents TSDB storage.
|
||||
type Storage struct {
|
||||
rowsAddedTotal atomic.Uint64
|
||||
|
||||
tooSmallTimestampRows atomic.Uint64
|
||||
tooBigTimestampRows atomic.Uint64
|
||||
|
||||
|
@ -552,7 +554,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())
|
||||
|
||||
|
@ -1606,8 +1608,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
|
||||
|
@ -1629,7 +1629,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 a new issue