diff --git a/tsdb/record/record.go b/tsdb/record/record.go index 12a404739..687b7e50b 100644 --- a/tsdb/record/record.go +++ b/tsdb/record/record.go @@ -44,6 +44,21 @@ const ( Exemplars Type = 4 ) +func (rt Type) String() string { + switch rt { + case Series: + return "series" + case Samples: + return "samples" + case Exemplars: + return "exemplars" + case Tombstones: + return "tombstones" + default: + return "unknown" + } +} + // ErrNotFound is returned if a looked up resource was not found. Duplicate ErrNotFound from head.go. var ErrNotFound = errors.New("not found") diff --git a/tsdb/wal/watcher.go b/tsdb/wal/watcher.go index 7b026b4ea..5b949fc00 100644 --- a/tsdb/wal/watcher.go +++ b/tsdb/wal/watcher.go @@ -481,7 +481,7 @@ func (w *Watcher) readSegment(r *LiveReader, segmentNum int, tail bool) error { ) for r.Next() && !isClosed(w.quit) { rec := r.Record() - w.recordsReadMetric.WithLabelValues(recordType(dec.Type(rec))).Inc() + w.recordsReadMetric.WithLabelValues(dec.Type(rec).String()).Inc() switch dec.Type(rec) { case record.Series: @@ -554,7 +554,7 @@ func (w *Watcher) readSegmentForGC(r *LiveReader, segmentNum int, _ bool) error ) for r.Next() && !isClosed(w.quit) { rec := r.Record() - w.recordsReadMetric.WithLabelValues(recordType(dec.Type(rec))).Inc() + w.recordsReadMetric.WithLabelValues(dec.Type(rec).String()).Inc() switch dec.Type(rec) { case record.Series: @@ -583,19 +583,6 @@ func (w *Watcher) SetStartTime(t time.Time) { w.startTimestamp = timestamp.FromTime(t) } -func recordType(rt record.Type) string { - switch rt { - case record.Series: - return "series" - case record.Samples: - return "samples" - case record.Tombstones: - return "tombstones" - default: - return "unknown" - } -} - type segmentReadFn func(w *Watcher, r *LiveReader, segmentNum int, tail bool) error // Read all the series records from a Checkpoint directory.