优化只保留5位小数 (#878)

* 优化只保留5位小数

* 优化小数点保留方法
master
zheng 3 years ago committed by GitHub
parent 483b353494
commit b43f196d86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -5,6 +5,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"math"
"strconv" "strconv"
"strings" "strings"
"time" "time"
@ -52,6 +53,8 @@ func (m *FalconMetric) Clean(ts int64) error {
return fmt.Errorf("unparseable value %v", v) return fmt.Errorf("unparseable value %v", v)
} }
m.Value = math.Round(m.Value*100000) / 100000
// if timestamp bigger than 32 bits, likely in milliseconds // if timestamp bigger than 32 bits, likely in milliseconds
if m.Timestamp > 0xffffffff { if m.Timestamp > 0xffffffff {
m.Timestamp /= 1000 m.Timestamp /= 1000

@ -5,6 +5,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"math"
"strconv" "strconv"
"strings" "strings"
"time" "time"
@ -52,6 +53,8 @@ func (m *HTTPMetric) Clean(ts int64) error {
return fmt.Errorf("unparseable value %v", v) return fmt.Errorf("unparseable value %v", v)
} }
m.Value = math.Round(m.Value*100000) / 100000
// if timestamp bigger than 32 bits, likely in milliseconds // if timestamp bigger than 32 bits, likely in milliseconds
if m.Timestamp > 0xffffffff { if m.Timestamp > 0xffffffff {
m.Timestamp /= 1000 m.Timestamp /= 1000

Loading…
Cancel
Save