fix NaN too null conversion and restore duration

This commit is contained in:
Lou Knauer 2022-01-31 16:34:42 +01:00
parent 371afe5ab5
commit 407e650745
4 changed files with 11 additions and 6 deletions

View File

@ -129,7 +129,7 @@ JWT="eyJ0eXAiOiJKV1QiLCJhbGciOiJFZERTQSJ9.eyJ1c2VyIjoiYWRtaW4iLCJyb2xlcyI6WyJST0
# If the collector and store and nats-server have been running for at least 60 seconds on the same host, you may run:
curl -H "Authorization: Bearer $JWT" -D - "http://localhost:8080/api/query" -d "{ \"cluster\": \"testcluster\", \"from\": $(expr $(date +%s) - 60), \"to\": $(date +%s), \"queries\": [{
\"metric\": \"load_one\",
\"hostname\": \"$(hostname)\"
\"host\": \"$(hostname)\"
}] }"
# ...

View File

@ -46,11 +46,16 @@ type FloatArray []Float
func (fa FloatArray) MarshalJSON() ([]byte, error) {
buf := make([]byte, 0, 2+len(fa)*8)
buf = append(buf, '[')
if len(fa) > 0 {
buf = strconv.AppendFloat(buf, float64(fa[0]), 'f', 1, 32)
for i := 1; i < len(fa); i++ {
for i := 0; i < len(fa); i++ {
if i != 0 {
buf = append(buf, ',')
}
if fa[i].IsNaN() {
buf = append(buf, `null`...)
} else {
buf = strconv.AppendFloat(buf, float64(fa[i]), 'f', 1, 32)
}
}
buf = append(buf, ']')

View File

@ -157,7 +157,7 @@ func main() {
log.Fatal(err)
}
restoreFrom := startupTime.Add(d)
restoreFrom := startupTime.Add(-d)
log.Printf("Loading checkpoints newer than %s\n", restoreFrom.Format(time.RFC3339))
files, err := memoryStore.FromCheckpoint(conf.Checkpoints.RootDir, restoreFrom.Unix())
if err != nil {

View File

@ -114,5 +114,5 @@ func (l *level) findBuffers(selector Selector, offset int, f func(b *buffer) err
return nil
}
panic("impossible")
return nil
}