mirror of
https://github.com/ClusterCockpit/cc-metric-store.git
synced 2024-11-10 05:07:25 +01:00
51 lines
975 B
Go
51 lines
975 B
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
)
|
|
|
|
func (b *buffer) debugDump(w *bufio.Writer) {
|
|
if b.prev != nil {
|
|
b.prev.debugDump(w)
|
|
}
|
|
|
|
end := ""
|
|
if b.next != nil {
|
|
end = " -> "
|
|
}
|
|
|
|
to := b.start + b.frequency*int64(len(b.data))
|
|
fmt.Fprintf(w, "buffer(from=%d, len=%d, to=%d)%s", b.start, len(b.data), to, end)
|
|
}
|
|
|
|
func (l *level) debugDump(w *bufio.Writer, m *MemoryStore, indent string) error {
|
|
l.lock.RLock()
|
|
defer l.lock.RUnlock()
|
|
|
|
for name, minfo := range m.metrics {
|
|
b := l.metrics[minfo.offset]
|
|
if b != nil {
|
|
fmt.Fprintf(w, "%smetric '%s': ", indent, name)
|
|
b.debugDump(w)
|
|
fmt.Fprint(w, "\n")
|
|
}
|
|
}
|
|
|
|
if l.children != nil {
|
|
fmt.Fprintf(w, "%schildren:\n", indent)
|
|
for name, lvl := range l.children {
|
|
fmt.Fprintf(w, "%s'%s':\n", indent, name)
|
|
lvl.debugDump(w, m, "\t"+indent)
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (m *MemoryStore) DebugDump(w *bufio.Writer) error {
|
|
fmt.Fprintf(w, "MemoryStore:\n")
|
|
m.root.debugDump(w, m, " ")
|
|
return w.Flush()
|
|
}
|