diff --git a/cmd/tsdb/main.go b/cmd/tsdb/main.go index 2cece4d78..625fb73b0 100644 --- a/cmd/tsdb/main.go +++ b/cmd/tsdb/main.go @@ -90,7 +90,7 @@ func (b *writeBenchmark) run(cmd *cobra.Command, args []string) { dir := filepath.Join(b.outPath, "storage") - st, err := tsdb.Open(dir, nil, &tsdb.Options{ + st, err := tsdb.Open(dir, nil, nil, &tsdb.Options{ WALFlushInterval: 200 * time.Millisecond, RetentionDuration: 1 * 24 * 60 * 60 * 1000, // 1 days in milliseconds MinBlockDuration: 3 * 60 * 60 * 1000, // 2 hours in milliseconds diff --git a/db.go b/db.go index 4ab2bb398..9747e7760 100644 --- a/db.go +++ b/db.go @@ -132,7 +132,7 @@ func newDBMetrics(r prometheus.Registerer) *dbMetrics { } // Open returns a new DB in the given directory. -func Open(dir string, l log.Logger, opts *Options) (db *DB, err error) { +func Open(dir string, l log.Logger, r prometheus.Registerer, opts *Options) (db *DB, err error) { if err := os.MkdirAll(dir, 0777); err != nil { return nil, err } @@ -154,9 +154,6 @@ func Open(dir string, l log.Logger, opts *Options) (db *DB, err error) { l = log.NewContext(l).With("ts", log.DefaultTimestampUTC, "caller", log.DefaultCaller) } - // var r prometheus.Registerer - r := prometheus.DefaultRegisterer - if opts == nil { opts = DefaultOptions } @@ -736,7 +733,7 @@ func isPowTwo(x int) bool { } // OpenPartitioned or create a new DB. -func OpenPartitioned(dir string, n int, l log.Logger, opts *Options) (*PartitionedDB, error) { +func OpenPartitioned(dir string, n int, l log.Logger, r prometheus.Registerer, opts *Options) (*PartitionedDB, error) { if !isPowTwo(n) { return nil, errors.Errorf("%d is not a power of two", n) } @@ -764,7 +761,7 @@ func OpenPartitioned(dir string, n int, l log.Logger, opts *Options) (*Partition l := log.NewContext(l).With("partition", i) d := partitionDir(dir, i) - s, err := Open(d, l, opts) + s, err := Open(d, l, r, opts) if err != nil { return nil, fmt.Errorf("initializing partition %q failed: %s", d, err) }