From 4397b4d508318ae3f89aa32a9bfde92d70d1c351 Mon Sep 17 00:00:00 2001 From: Fabian Reinartz Date: Tue, 28 Feb 2017 09:33:14 +0100 Subject: [PATCH] *: pass Prometheus registry into storage --- cmd/prometheus/main.go | 9 ++++++++- storage/tsdb/tsdb.go | 5 +++-- util/testutil/storage.go | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/cmd/prometheus/main.go b/cmd/prometheus/main.go index ae5998eff..33a34d0be 100644 --- a/cmd/prometheus/main.go +++ b/cmd/prometheus/main.go @@ -70,6 +70,13 @@ func Main() int { return 0 } + // go func() { + // for { + // time.Sleep(30 * time.Second) + // debug.FreeOSMemory() + // } + // }() + log.Infoln("Starting prometheus", version.Info()) log.Infoln("Build context", version.BuildContext()) @@ -78,7 +85,7 @@ func Main() int { reloadables []Reloadable ) - localStorage, err := tsdb.Open(cfg.localStoragePath, &cfg.tsdb) + localStorage, err := tsdb.Open(cfg.localStoragePath, prometheus.DefaultRegisterer, &cfg.tsdb) if err != nil { log.Errorf("Opening storage failed: %s", err) return 1 diff --git a/storage/tsdb/tsdb.go b/storage/tsdb/tsdb.go index c0dc0f96b..519b63946 100644 --- a/storage/tsdb/tsdb.go +++ b/storage/tsdb/tsdb.go @@ -6,6 +6,7 @@ import ( "github.com/fabxc/tsdb" tsdbLabels "github.com/fabxc/tsdb/labels" + "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/storage" ) @@ -36,8 +37,8 @@ type Options struct { } // Open returns a new storage backed by a tsdb database. -func Open(path string, opts *Options) (storage.Storage, error) { - db, err := tsdb.OpenPartitioned(path, 1, nil, &tsdb.Options{ +func Open(path string, r prometheus.Registerer, opts *Options) (storage.Storage, error) { + db, err := tsdb.OpenPartitioned(path, 1, nil, r, &tsdb.Options{ WALFlushInterval: 10 * time.Second, MinBlockDuration: uint64(opts.MinBlockDuration.Seconds() * 1000), MaxBlockDuration: uint64(opts.MaxBlockDuration.Seconds() * 1000), diff --git a/util/testutil/storage.go b/util/testutil/storage.go index 6aa341f5e..760a31546 100644 --- a/util/testutil/storage.go +++ b/util/testutil/storage.go @@ -20,7 +20,7 @@ func NewStorage(t T) storage.Storage { log.With("dir", dir).Debugln("opening test storage") - db, err := tsdb.Open(dir, &tsdb.Options{ + db, err := tsdb.Open(dir, nil, &tsdb.Options{ MinBlockDuration: 2 * time.Hour, MaxBlockDuration: 24 * time.Hour, AppendableBlocks: 10,