Browse Source

Recognize exemplar record type in WAL watcher metrics (#11008)

* Add exemplar record case

Signed-off-by: Levi Harrison <git@leviharrison.dev>

* recordType() -> Type.String()

Signed-off-by: Levi Harrison <git@leviharrison.dev>
pull/11034/head
Levi Harrison 2 years ago committed by GitHub
parent
commit
3d538351f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      tsdb/record/record.go
  2. 17
      tsdb/wal/watcher.go

15
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")

17
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.

Loading…
Cancel
Save