Skip to content

Commit

Permalink
File watch on shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
damemi committed Jun 13, 2023
1 parent e832088 commit 7654b46
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions exporter/collector/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,14 +599,18 @@ func (me *MetricsExporter) runWALReadAndExportLoop(ctx context.Context) {
// do one last final read/export then return
// otherwise the runner goroutine could leave some hanging metrics unexported
for {
fmt.Println("Reading WAL final time")
err := me.readWALAndExport(runCtx)
if err != nil {
if !errors.Is(err, wal.ErrOutOfRange) {
me.obs.log.Error(fmt.Sprintf("error flushing remaining WAL entries: %+v", err))
me.obs.log.Error(fmt.Sprintf("error flushing remaining WAL entries: %+v", err))
if errors.Is(err, wal.ErrOutOfRange) {
break
}
if errors.Is(err, wal.ErrNotFound) {
if err2 := me.watchWALFile(ctx); err2 != nil {
me.obs.log.Error(fmt.Sprintf("error flushing remaining WAL entries: %+v", err2))
break
}
}
fmt.Println(err)
break
}
}
return
Expand Down

0 comments on commit 7654b46

Please sign in to comment.