mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-21 03:16:00 -08:00
Serialize matrices correctly.
This commit is contained in:
parent
39b2e72eb0
commit
ebabaa46f4
|
@ -15,6 +15,7 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// A Fingerprint is a simplified representation of an entity---e.g., a hash of
|
// A Fingerprint is a simplified representation of an entity---e.g., a hash of
|
||||||
|
@ -45,6 +46,14 @@ type Metric map[LabelName]LabelValue
|
||||||
// remedied down the road.
|
// remedied down the road.
|
||||||
type SampleValue float32
|
type SampleValue float32
|
||||||
|
|
||||||
|
func (v SampleValue) MarshalJSON() ([]byte, error) {
|
||||||
|
return []byte(fmt.Sprintf("\"%f\"", v)), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s SamplePair) MarshalJSON() ([]byte, error) {
|
||||||
|
return []byte(fmt.Sprintf("{\"Value\": \"%f\", \"Timestamp\": %d}", s.Value, s.Timestamp.Unix())), nil
|
||||||
|
}
|
||||||
|
|
||||||
type Sample struct {
|
type Sample struct {
|
||||||
Metric Metric
|
Metric Metric
|
||||||
Value SampleValue
|
Value SampleValue
|
||||||
|
|
Loading…
Reference in a new issue