From 9672ade1912d9c81e06bf6f6241ae9924b47c0cc Mon Sep 17 00:00:00 2001 From: beorn7 Date: Thu, 25 Nov 2021 13:32:37 +0100 Subject: [PATCH] Promql: Add clarifying note to Point.MarshalJSON Signed-off-by: beorn7 --- promql/value.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/promql/value.go b/promql/value.go index 81af1ad9d..55cdc44d3 100644 --- a/promql/value.go +++ b/promql/value.go @@ -88,6 +88,14 @@ func (p Point) String() string { } // MarshalJSON implements json.Marshaler. +// +// 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. Therefore, this method is unused within Prometheus. It is +// still provided here as convenience for debugging and for other users of this +// code. Also note that the different marshaling implementations might lead to +// slightly different results in terms of formatting and rounding of the +// timestamp. func (p Point) MarshalJSON() ([]byte, error) { v := strconv.FormatFloat(p.V, 'f', -1, 64) return json.Marshal([...]interface{}{float64(p.T) / 1000, v})