Merge pull request #2093 from derailed/BUG_PointPrecision
Point Precision not getting marshaled correctly...pull/2104/head
commit
a4b133c601
|
@ -295,10 +295,12 @@ func (p *Point) MarshalJSON() ([]byte, error) {
|
|||
Tags map[string]string `json:"tags,omitempty"`
|
||||
Timestamp string `json:"timestamp,omitempty"`
|
||||
Fields map[string]interface{} `json:"fields,omitempty"`
|
||||
Precision string `json:"precision,omitempty"`
|
||||
}{
|
||||
Name: p.Name,
|
||||
Tags: p.Tags,
|
||||
Fields: p.Fields,
|
||||
Name: p.Name,
|
||||
Tags: p.Tags,
|
||||
Fields: p.Fields,
|
||||
Precision: p.Precision,
|
||||
}
|
||||
// Let it omit empty if it's really zero
|
||||
if !p.Timestamp.IsZero() {
|
||||
|
|
|
@ -332,7 +332,7 @@ func TestPoint_MarshalOmitempty(t *testing.T) {
|
|||
name: "with precision",
|
||||
point: client.Point{Name: "cpu", Fields: map[string]interface{}{"value": 1.1}, Precision: "ms"},
|
||||
now: now,
|
||||
expected: `{"name":"cpu","fields":{"value":1.1}}`,
|
||||
expected: `{"name":"cpu","fields":{"value":1.1},"precision":"ms"}`,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -390,14 +390,14 @@ func emptyTestServer() *httptest.Server {
|
|||
func TestBatchPoints_Normal(t *testing.T) {
|
||||
var bp client.BatchPoints
|
||||
data := []byte(`
|
||||
{
|
||||
"database": "foo",
|
||||
"retentionPolicy": "bar",
|
||||
"points": [
|
||||
{
|
||||
"name": "cpu",
|
||||
"tags": {
|
||||
"host": "server01"
|
||||
{
|
||||
"database": "foo",
|
||||
"retentionPolicy": "bar",
|
||||
"points": [
|
||||
{
|
||||
"name": "cpu",
|
||||
"tags": {
|
||||
"host": "server01"
|
||||
},
|
||||
"timestamp": 14244733039069373,
|
||||
"precision": "n",
|
||||
|
|
Loading…
Reference in New Issue