mirror of
https://github.com/ClusterCockpit/cc-metric-store.git
synced 2024-12-28 17:49:05 +01:00
Add unit for archive reader/writer
This commit is contained in:
parent
89acbe8db2
commit
051cba4666
@ -24,6 +24,7 @@ import (
|
|||||||
type CheckpointMetrics struct {
|
type CheckpointMetrics struct {
|
||||||
Frequency int64 `json:"frequency"`
|
Frequency int64 `json:"frequency"`
|
||||||
Start int64 `json:"start"`
|
Start int64 `json:"start"`
|
||||||
|
Unit string `json:"unit"`
|
||||||
Data []Float `json:"data"`
|
Data []Float `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,6 +37,7 @@ func (cm *CheckpointMetrics) MarshalJSON() ([]byte, error) {
|
|||||||
buf = strconv.AppendInt(buf, cm.Frequency, 10)
|
buf = strconv.AppendInt(buf, cm.Frequency, 10)
|
||||||
buf = append(buf, `,"start":`...)
|
buf = append(buf, `,"start":`...)
|
||||||
buf = strconv.AppendInt(buf, cm.Start, 10)
|
buf = strconv.AppendInt(buf, cm.Start, 10)
|
||||||
|
buf = append(buf, fmt.Sprintf(`,"unit":"%s"`, cm.Unit)...)
|
||||||
buf = append(buf, `,"data":[`...)
|
buf = append(buf, `,"data":[`...)
|
||||||
for i, x := range cm.Data {
|
for i, x := range cm.Data {
|
||||||
if i != 0 {
|
if i != 0 {
|
||||||
@ -179,6 +181,7 @@ func (l *level) toCheckpointFile(from, to int64, m *MemoryStore) (*CheckpointFil
|
|||||||
Frequency: b.frequency,
|
Frequency: b.frequency,
|
||||||
Start: start,
|
Start: start,
|
||||||
Data: data,
|
Data: data,
|
||||||
|
Unit: b.unit,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,6 +312,7 @@ func (l *level) loadFile(cf *CheckpointFile, m *MemoryStore) error {
|
|||||||
frequency: metric.Frequency,
|
frequency: metric.Frequency,
|
||||||
start: metric.Start,
|
start: metric.Start,
|
||||||
data: metric.Data[0:n:n], // Space is wasted here :(
|
data: metric.Data[0:n:n], // Space is wasted here :(
|
||||||
|
unit: "",
|
||||||
prev: nil,
|
prev: nil,
|
||||||
next: nil,
|
next: nil,
|
||||||
archived: true,
|
archived: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user