Move printing db.blocks to main.go
This commit is contained in:
parent
9945a67bff
commit
a41dad30fb
|
@ -60,7 +60,7 @@ func main() {
|
|||
if err != nil {
|
||||
exitWithError(err)
|
||||
}
|
||||
db.PrintBlocks()
|
||||
printBlocks(db.Blocks())
|
||||
}
|
||||
flag.CommandLine.Set("log.level", "debug")
|
||||
}
|
||||
|
@ -331,3 +331,21 @@ func exitWithError(err error) {
|
|||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func printBlocks(blocks []tsdb.DiskBlock) {
|
||||
tw := tsdb.GetNewTabWriter(os.Stdout)
|
||||
defer tw.Flush()
|
||||
|
||||
fmt.Fprintln(tw, "BLOCK ULID\tMIN TIME\tMAX TIME\tNUM SAMPLES\tNUM CHUNKS\tNUM SERIES")
|
||||
for _, b := range blocks {
|
||||
fmt.Fprintf(tw,
|
||||
"%v\t%v\t%v\t%v\t%v\t%v\n",
|
||||
b.Meta().ULID,
|
||||
b.Meta().MinTime,
|
||||
b.Meta().MaxTime,
|
||||
b.Meta().Stats.NumSamples,
|
||||
b.Meta().Stats.NumChunks,
|
||||
b.Meta().Stats.NumSeries,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
21
db.go
21
db.go
|
@ -228,27 +228,6 @@ func (db *DB) Dir() string {
|
|||
return db.dir
|
||||
}
|
||||
|
||||
func (db *DB) PrintBlocks() {
|
||||
db.mtx.RLock()
|
||||
defer db.mtx.RUnlock()
|
||||
|
||||
tw := GetNewTabWriter(os.Stdout)
|
||||
defer tw.Flush()
|
||||
|
||||
fmt.Fprintln(tw, "BLOCK ULID\tMIN TIME\tMAX TIME\tNUM SAMPLES\tNUM CHUNKS\tNUM SERIES")
|
||||
for _, b := range db.blocks {
|
||||
fmt.Fprintf(tw,
|
||||
"%v\t%v\t%v\t%v\t%v\t%v\n",
|
||||
b.Meta().ULID,
|
||||
b.Meta().MinTime,
|
||||
b.Meta().MaxTime,
|
||||
b.Meta().Stats.NumSamples,
|
||||
b.Meta().Stats.NumChunks,
|
||||
b.Meta().Stats.NumSeries,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func (db *DB) run() {
|
||||
defer close(db.donec)
|
||||
|
||||
|
|
Loading…
Reference in New Issue