mirror of
https://github.com/ClusterCockpit/cc-metric-store.git
synced 2024-11-10 05:07:25 +01:00
Add unit to buffers
This commit is contained in:
parent
e71e1b123b
commit
5e5586f319
4
api.go
4
api.go
@ -183,7 +183,7 @@ type ApiQueryRequest struct {
|
|||||||
From int64 `json:"from"`
|
From int64 `json:"from"`
|
||||||
To int64 `json:"to"`
|
To int64 `json:"to"`
|
||||||
WithStats bool `json:"with-stats"`
|
WithStats bool `json:"with-stats"`
|
||||||
WithUnit bool `json:"with-unit"`
|
WithUnit bool `json:"with-unit,omitempty"`
|
||||||
WithData bool `json:"with-data"`
|
WithData bool `json:"with-data"`
|
||||||
WithPadding bool `json:"with-padding"`
|
WithPadding bool `json:"with-padding"`
|
||||||
Queries []ApiQuery `json:"queries"`
|
Queries []ApiQuery `json:"queries"`
|
||||||
@ -303,7 +303,7 @@ func handleQuery(rw http.ResponseWriter, r *http.Request) {
|
|||||||
if req.WithPadding {
|
if req.WithPadding {
|
||||||
data.PadDataWithNull(req.From, req.To, query.Metric)
|
data.PadDataWithNull(req.From, req.To, query.Metric)
|
||||||
}
|
}
|
||||||
if req.WithUnit {
|
if req.WithUnit && len(unit) > 0 {
|
||||||
data.Unit = unit
|
data.Unit = unit
|
||||||
}
|
}
|
||||||
if !req.WithData {
|
if !req.WithData {
|
||||||
|
@ -24,7 +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"`
|
Unit string `json:"unit,omitempty"`
|
||||||
Data []Float `json:"data"`
|
Data []Float `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,7 +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: "",
|
unit: metric.Unit,
|
||||||
prev: nil,
|
prev: nil,
|
||||||
next: nil,
|
next: nil,
|
||||||
archived: true,
|
archived: true,
|
||||||
|
3
debug.go
3
debug.go
@ -21,6 +21,9 @@ func (b *buffer) debugDump(buf []byte) []byte {
|
|||||||
if b.archived {
|
if b.archived {
|
||||||
buf = append(buf, `,"saved":true`...)
|
buf = append(buf, `,"saved":true`...)
|
||||||
}
|
}
|
||||||
|
if b.unit != "" {
|
||||||
|
buf = append(buf, fmt.Sprintf(`,"unit":"%s"`, b.unit)...)
|
||||||
|
}
|
||||||
if b.next != nil {
|
if b.next != nil {
|
||||||
buf = append(buf, `},`...)
|
buf = append(buf, `},`...)
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user