Skip to content
This repository has been archived by the owner on Aug 13, 2019. It is now read-only.

Commit

Permalink
Copy FromTime function from timestamp package so we don't have to vendor
Browse files Browse the repository at this point in the history
something from Prometheus.

Signed-off-by: Callum Styan <[email protected]>
  • Loading branch information
cstyan committed Jun 4, 2019
1 parent e679638 commit 7dfb442
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions wal/wal_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/go-kit/kit/log/level"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/prometheus/pkg/timestamp"
"github.com/prometheus/tsdb/fileutil"
"github.com/prometheus/tsdb/record"
)
Expand Down Expand Up @@ -79,6 +78,13 @@ var (
)
)

// This function is copied from prometheus/prometheus/pkg/timestamp to avoid adding vendor to TSDB repo.

// FromTime returns a new millisecond timestamp from a time.
func FromTime(t time.Time) int64 {
return t.Unix()*1000 + int64(t.Nanosecond())/int64(time.Millisecond)
}

func init() {
prometheus.MustRegister(watcherRecordsRead)
prometheus.MustRegister(watcherRecordDecodeFails)
Expand Down Expand Up @@ -169,7 +175,7 @@ func (w *WALWatcher) loop() {

// We may encourter failures processing the WAL; we should wait and retry.
for !isClosed(w.quit) {
w.startTime = timestamp.FromTime(time.Now())
w.startTime = FromTime(time.Now())
if err := w.run(); err != nil {
level.Error(w.logger).Log("msg", "error tailing WAL", "err", err)
}
Expand Down

0 comments on commit 7dfb442

Please sign in to comment.