Skip to content

Commit

Permalink
chore(parsers.xpath): Add tracing mode to output empty-node-selection…
Browse files Browse the repository at this point in the history
… messages (#14939)
  • Loading branch information
srebhan committed Mar 6, 2024
1 parent 9a9bb16 commit 7adc32e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions plugins/parsers/xpath/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ XPath expressions.
## Currently, CBOR, protobuf, msgpack and JSON support native data-types.
# xpath_native_types = false

## Trace empty node selections for debugging
## This will only produce output in debugging mode.
# xpath_trace = false

## Multiple parsing sections are allowed
[[inputs.file.xpath]]
## Optional: XPath-query to select a subset of nodes from the XML document.
Expand Down
3 changes: 2 additions & 1 deletion plugins/parsers/xpath/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type Parser struct {
PrintDocument bool `toml:"xpath_print_document"`
AllowEmptySelection bool `toml:"xpath_allow_empty_selection"`
NativeTypes bool `toml:"xpath_native_types"`
Trace bool `toml:"xpath_trace"`
Configs []Config `toml:"xpath"`
DefaultMetricName string `toml:"-"`
DefaultTags map[string]string `toml:"-"`
Expand Down Expand Up @@ -623,7 +624,7 @@ func (p *Parser) constructFieldName(root, node dataNode, name string, expand boo
}

func (p *Parser) debugEmptyQuery(operation string, root dataNode, initialquery string) {
if p.Log == nil {
if p.Log == nil || !p.Trace {
return
}

Expand Down

0 comments on commit 7adc32e

Please sign in to comment.