aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/prometheus/common/model/value_float.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/prometheus/common/model/value_float.go')
-rw-r--r--vendor/github.com/prometheus/common/model/value_float.go27
1 files changed, 9 insertions, 18 deletions
diff --git a/vendor/github.com/prometheus/common/model/value_float.go b/vendor/github.com/prometheus/common/model/value_float.go
index 8b59571a3..0f615a705 100644
--- a/vendor/github.com/prometheus/common/model/value_float.go
+++ b/vendor/github.com/prometheus/common/model/value_float.go
@@ -18,15 +18,8 @@ import (
"fmt"
"math"
"strconv"
- "unsafe"
-
- jsoniter "github.com/json-iterator/go"
)
-func init() {
- jsoniter.RegisterTypeEncoderFunc("model.SamplePair", marshalSamplePairJSON, marshalJSONIsEmpty)
-}
-
var (
// ZeroSamplePair is the pseudo zero-value of SamplePair used to signal a
// non-existing sample pair. It is a SamplePair with timestamp Earliest and
@@ -78,18 +71,16 @@ type SamplePair struct {
Value SampleValue
}
-// marshalSamplePairJSON writes `[ts, "val"]`.
-func marshalSamplePairJSON(ptr unsafe.Pointer, stream *jsoniter.Stream) {
- p := *((*SamplePair)(ptr))
- stream.WriteArrayStart()
- MarshalTimestamp(int64(p.Timestamp), stream)
- stream.WriteMore()
- MarshalValue(float64(p.Value), stream)
- stream.WriteArrayEnd()
-}
-
func (s SamplePair) MarshalJSON() ([]byte, error) {
- return jsoniter.ConfigCompatibleWithStandardLibrary.Marshal(s)
+ t, err := json.Marshal(s.Timestamp)
+ if err != nil {
+ return nil, err
+ }
+ v, err := json.Marshal(s.Value)
+ if err != nil {
+ return nil, err
+ }
+ return []byte(fmt.Sprintf("[%s,%s]", t, v)), nil
}
// UnmarshalJSON implements json.Unmarshaler.