newJsonParser function is now unexported, must use NewParser(config)

This commit is contained in:
Max U
2018-06-28 15:35:20 -07:00
parent 7f2b2a08ae
commit 4db667573a
11 changed files with 81 additions and 51 deletions

View File

@@ -473,37 +473,4 @@ func TestJSONParseNestedArray(t *testing.T) {
log.Printf("m[0] name: %v, tags: %v, fields: %v", metrics[0].Name(), metrics[0].Tags(), metrics[0].Fields())
require.NoError(t, err)
require.Equal(t, len(parser.TagKeys), len(metrics[0].Tags()))
t.Error()
}
func TestJSONPathFunctionality(t *testing.T) {
testString := `{
"total_devices": 5,
"total_threads": 10,
"shares": {
"total": 5,
"accepted": 5,
"rejected": 0,
"avg_find_time": 4,
"tester": "work",
"tester2": "don't want this",
"tester3": {
"hello":"sup",
"fun":"money",
"break":9
}
}
}`
parser := JSONParser{
MetricName: "json_test",
TagKeys: []string{"total_devices", "total_threads", "shares_tester3_fun"},
FieldKeys: []string{"shares_tester", "shares_tester3_break"},
TagPaths: map[string]string{"name_test": "$.shares.total"},
}
metrics, err := parser.Parse([]byte(testString))
log.Printf("m[0] name: %v, tags: %v, fields: %v", metrics[0].Name(), metrics[0].Tags(), metrics[0].Fields())
assert.NoError(t, err)
t.Error()
}