Fix newline escaping in line protocol (#3992)

(cherry picked from commit e4f8a82ee6)
This commit is contained in:
Daniel Nelson
2018-04-09 15:29:52 -07:00
committed by Daniel Nelson
parent 5f0fbc7d30
commit b5babc3f00
5 changed files with 5302 additions and 5084 deletions

View File

@@ -261,6 +261,50 @@ var tests = []struct {
),
output: []byte("cpu abc=123i 1519194109000000042\ncpu def=456i 1519194109000000042\n"),
},
{
name: "name newline",
input: MustMetric(
metric.New(
"c\npu",
map[string]string{},
map[string]interface{}{
"value": 42,
},
time.Unix(0, 0),
),
),
output: []byte("c\\npu value=42i 0\n"),
},
{
name: "tag newline",
input: MustMetric(
metric.New(
"cpu",
map[string]string{
"host": "x\ny",
},
map[string]interface{}{
"value": 42,
},
time.Unix(0, 0),
),
),
output: []byte("cpu,host=x\\ny value=42i 0\n"),
},
{
name: "string newline",
input: MustMetric(
metric.New(
"cpu",
map[string]string{},
map[string]interface{}{
"value": "x\ny",
},
time.Unix(0, 0),
),
),
output: []byte("cpu value=\"x\\ny\" 0\n"),
},
{
name: "need more space",
maxBytes: 32,