From df7db4ac0767cf9c58e64f3af817ec80ac4fd61c Mon Sep 17 00:00:00 2001 From: Goutham Veeramachaneni Date: Sun, 19 Mar 2017 21:03:09 +0530 Subject: [PATCH 1/2] Update kit/log To New API NewContext has been removed couple of weeks back. Ref: https://github.com/go-kit/kit/releases/tag/v0.4.0 --- db.go | 2 +- head.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/db.go b/db.go index 4de657a39..a89665e27 100644 --- a/db.go +++ b/db.go @@ -157,7 +157,7 @@ func Open(dir string, l log.Logger, r prometheus.Registerer, opts *Options) (db if l == nil { l = log.NewLogfmtLogger(os.Stdout) - l = log.NewContext(l).With("ts", log.DefaultTimestampUTC, "caller", log.DefaultCaller) + l = log.With(l, "ts", log.DefaultTimestampUTC, "caller", log.DefaultCaller) } if opts == nil { diff --git a/head.go b/head.go index eed2ff222..4bebb379c 100644 --- a/head.go +++ b/head.go @@ -86,7 +86,7 @@ func createHeadBlock(dir string, seq int, l log.Logger, mint, maxt int64) (*head // openHeadBlock creates a new empty head block. func openHeadBlock(dir string, l log.Logger) (*headBlock, error) { - wal, err := OpenWAL(dir, log.NewContext(l).With("component", "wal"), 5*time.Second) + wal, err := OpenWAL(dir, log.With(l, "component", "wal"), 5*time.Second) if err != nil { return nil, err } From 761e4768f31782a13cecf770327ee4767ce59334 Mon Sep 17 00:00:00 2001 From: Goutham Veeramachaneni Date: Sun, 19 Mar 2017 21:35:01 +0530 Subject: [PATCH 2/2] Lint and Vet Fixes --- chunks.go | 2 +- chunks/xor.go | 1 + cmd/tsdb/main.go | 6 +++--- labels/selector.go | 6 +++++- querier.go | 4 ++-- wal.go | 1 + 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/chunks.go b/chunks.go index b3aaeb206..8fadeb3f1 100644 --- a/chunks.go +++ b/chunks.go @@ -15,7 +15,7 @@ import ( ) const ( - // MagicSeries 4 bytes at the head of series file. + // MagicChunks is 4 bytes at the head of series file. MagicChunks = 0x85BD40DD ) diff --git a/chunks/xor.go b/chunks/xor.go index 8acdda6ee..2316c1d4f 100644 --- a/chunks/xor.go +++ b/chunks/xor.go @@ -19,6 +19,7 @@ func NewXORChunk() *XORChunk { return &XORChunk{b: &bstream{stream: b, count: 0}} } +// Encoding returns the encoding type. func (c *XORChunk) Encoding() Encoding { return EncXOR } diff --git a/cmd/tsdb/main.go b/cmd/tsdb/main.go index 575582431..24c836946 100644 --- a/cmd/tsdb/main.go +++ b/cmd/tsdb/main.go @@ -237,21 +237,21 @@ func (b *writeBenchmark) startProfiling() { // Start CPU profiling. b.cpuprof, err = os.Create(filepath.Join(b.outPath, "cpu.prof")) if err != nil { - exitWithError(fmt.Errorf("bench: could not create cpu profile: %v\n", err)) + exitWithError(fmt.Errorf("bench: could not create cpu profile: %v", err)) } pprof.StartCPUProfile(b.cpuprof) // Start memory profiling. b.memprof, err = os.Create(filepath.Join(b.outPath, "mem.prof")) if err != nil { - exitWithError(fmt.Errorf("bench: could not create memory profile: %v\n", err)) + exitWithError(fmt.Errorf("bench: could not create memory profile: %v", err)) } runtime.MemProfileRate = 4096 // Start fatal profiling. b.blockprof, err = os.Create(filepath.Join(b.outPath, "block.prof")) if err != nil { - exitWithError(fmt.Errorf("bench: could not create block profile: %v\n", err)) + exitWithError(fmt.Errorf("bench: could not create block profile: %v", err)) } runtime.SetBlockProfileRate(1) } diff --git a/labels/selector.go b/labels/selector.go index 0bcf5380c..07c0347b0 100644 --- a/labels/selector.go +++ b/labels/selector.go @@ -23,11 +23,15 @@ type Matcher interface { Matches(v string) bool } +// EqualMatcher matches on equality. type EqualMatcher struct { name, value string } -func (m *EqualMatcher) Name() string { return m.name } +// Name implements Matcher interface. +func (m *EqualMatcher) Name() string { return m.name } + +// Matches implements Matcher interface. func (m *EqualMatcher) Matches(v string) bool { return v == m.value } // NewEqualMatcher returns a new matcher matching an exact label value. diff --git a/querier.go b/querier.go index c027a8dc0..f68c3627b 100644 --- a/querier.go +++ b/querier.go @@ -480,7 +480,7 @@ type SeriesIterator interface { // If there's no value exactly at ts, it advances to the last value // before tt. Seek(t int64) bool - // Values returns the current timestamp/value pair. + // At returns the current timestamp/value pair. At() (t int64, v float64) // Next advances the iterator by one. Next() bool @@ -693,7 +693,7 @@ func (b *BufferedSeriesIterator) Next() bool { return ok } -// Values returns the current element of the iterator. +// At returns the current element of the iterator. func (b *BufferedSeriesIterator) At() (int64, float64) { return b.it.At() } diff --git a/wal.go b/wal.go index 2a49dcf41..6ccaad470 100644 --- a/wal.go +++ b/wal.go @@ -214,6 +214,7 @@ func (w *WAL) tail() *os.File { return w.files[len(w.files)-1] } +// Sync flushes the changes to disk. func (w *WAL) Sync() error { w.mtx.Lock() defer w.mtx.Unlock()