We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 16e2a6a + 8e743bb commit 63537eaCopy full SHA for 63537ea
1 file changed
promql/value.go
@@ -77,9 +77,6 @@ func (s Series) String() string {
77
}
78
79
// Point represents a single data point for a given timestamp.
80
-//
81
-// Note that Point's JSON marshaling is done in an optimized fashion in
82
-// web/api/v1/api.go. Therefore, no MarshalJSON method is provided here.
83
type Point struct {
84
T int64
85
V float64
@@ -90,6 +87,12 @@ func (p Point) String() string {
90
87
return fmt.Sprintf("%v @[%v]", v, p.T)
91
88
92
89
+// MarshalJSON implements json.Marshaler.
+func (p Point) MarshalJSON() ([]byte, error) {
+ v := strconv.FormatFloat(p.V, 'f', -1, 64)
93
+ return json.Marshal([...]interface{}{float64(p.T) / 1000, v})
94
+}
95
+
96
// Sample is a single sample belonging to a metric.
97
type Sample struct {
98
Point
0 commit comments