*: pass Prometheus registry into storage

This commit is contained in:
Fabian Reinartz 2017-02-28 09:33:14 +01:00
parent cc0ff26f1f
commit 4397b4d508
3 changed files with 12 additions and 4 deletions

View file

@ -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

View file

@ -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),

View file

@ -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,