From 427425cc9f477db22a8b3b1e832c965033322a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Rabenstein?= Date: Thu, 25 Nov 2021 08:08:24 +0100 Subject: [PATCH] promql: Remove unused Point.MarshalJSON method (#9860) JSON marshaling is only needed for the HTTP API. Since Point is such a frequently marshaled type, it gets an optimized treatment directly in web/api/v1/api.go. The MarshalJSON method still provided in the promql package is therefore unused and its existence is confusing. Signed-off-by: beorn7 --- promql/value.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/promql/value.go b/promql/value.go index 81af1ad9d..176b85696 100644 --- a/promql/value.go +++ b/promql/value.go @@ -77,6 +77,9 @@ func (s Series) String() string { } // Point represents a single data point for a given timestamp. +// +// Note that Point's JSON marshaling is done in an optimized fashion in +// web/api/v1/api.go. Therefore, no MarshalJSON method is provided here. type Point struct { T int64 V float64 @@ -87,12 +90,6 @@ func (p Point) String() string { return fmt.Sprintf("%v @[%v]", v, p.T) } -// MarshalJSON implements json.Marshaler. -func (p Point) MarshalJSON() ([]byte, error) { - v := strconv.FormatFloat(p.V, 'f', -1, 64) - return json.Marshal([...]interface{}{float64(p.T) / 1000, v}) -} - // Sample is a single sample belonging to a metric. type Sample struct { Point