Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bump github.com/tidwall/gjson from 1.10.2 to 1.14.1 #11264

Merged
merged 2 commits into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ require (
github.com/stretchr/testify v1.7.1
github.com/tbrandon/mbserver v0.0.0-20170611213546-993e1772cc62
github.com/testcontainers/testcontainers-go v0.12.0
github.com/tidwall/gjson v1.10.2
github.com/tidwall/gjson v1.14.1
github.com/tinylib/msgp v1.1.6
github.com/vapourismo/knx-go v0.0.0-20211128234507-8198fa17db36
github.com/vjeantet/grok v1.0.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2176,8 +2176,8 @@ github.com/tedsuo/ifrit v0.0.0-20180802180643-bea94bb476cc/go.mod h1:eyZnKCc955u
github.com/testcontainers/testcontainers-go v0.12.0 h1:SK0NryGHIx7aifF6YqReORL18aGAA4bsDPtikDVCEyg=
github.com/testcontainers/testcontainers-go v0.12.0/go.mod h1:SIndOQXZng0IW8iWU1Js0ynrfZ8xcxrTtDfF6rD2pxs=
github.com/tetafro/godot v1.4.4/go.mod h1:FVDd4JuKliW3UgjswZfJfHq4vAx0bD/Jd5brJjGeaz4=
github.com/tidwall/gjson v1.10.2 h1:APbLGOM0rrEkd8WBw9C24nllro4ajFuJu0Sc9hRz8Bo=
github.com/tidwall/gjson v1.10.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.14.1 h1:iymTbGkQBhveq21bEvAQ81I0LEBork8BFe1CUZXdyuo=
github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
Expand Down
16 changes: 11 additions & 5 deletions plugins/parsers/json_v2/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ func (p *Parser) processMetric(input []byte, data []DataSet, tag bool, timestamp
map[string]interface{}{},
timestamp,
),
Result: result,
Result: result,
ParentIndex: result.Index,
}

// Expand all array's and nested arrays into separate metrics
Expand Down Expand Up @@ -296,9 +297,10 @@ func (p *Parser) expandArray(result MetricNode, timestamp time.Time) ([]telegraf
)
if val.IsObject() {
n := result
n.ParentIndex += val.Index
n.Metric = m
n.Result = val
n.Index = val.Index - result.Index
n.ParentIndex = n.Index + result.ParentIndex
r, err := p.combineObject(n, timestamp)
if err != nil {
return false
Expand All @@ -315,9 +317,10 @@ func (p *Parser) expandArray(result MetricNode, timestamp time.Time) ([]telegraf

mergeMetric(result.Metric, m)
n := result
n.ParentIndex += val.Index
n.Metric = m
n.Result = val
n.Index = val.Index - result.Index
n.ParentIndex = n.Index + result.ParentIndex
r, err := p.expandArray(n, timestamp)
if err != nil {
return false
Expand Down Expand Up @@ -454,15 +457,16 @@ func (p *Parser) processObjects(input []byte, objects []JSONObject, timestamp ti
}

rootObject := MetricNode{
ParentIndex: 0,
Metric: metric.New(
p.measurementName,
map[string]string{},
map[string]interface{}{},
timestamp,
),
Result: result,
Result: result,
ParentIndex: 0,
}

metrics, err := p.expandArray(rootObject, timestamp)
if err != nil {
return nil, err
Expand Down Expand Up @@ -534,6 +538,8 @@ func (p *Parser) combineObject(result MetricNode, timestamp time.Time) ([]telegr
return false
}
} else {
arrayNode.Index -= result.Index
arrayNode.ParentIndex -= result.Index
r, err := p.expandArray(arrayNode, timestamp)
if err != nil {
return false
Expand Down