Skip to content
This repository has been archived by the owner on May 25, 2022. It is now read-only.

Kv parser #307

Closed
wants to merge 75 commits into from
Closed

Kv parser #307

wants to merge 75 commits into from

Conversation

jsirianni
Copy link
Member

@jsirianni jsirianni commented Nov 16, 2021

See #459

@jsirianni jsirianni requested review from djaglowski and a team November 16, 2021 21:13
@codecov
Copy link

codecov bot commented Nov 16, 2021

Codecov Report

Merging #307 (2c6ae2f) into main (962bfd8) will increase coverage by 0.2%.
The diff coverage is 100.0%.

Impacted file tree graph

@@           Coverage Diff           @@
##            main    #307     +/-   ##
=======================================
+ Coverage   77.1%   77.4%   +0.2%     
=======================================
  Files         94      95      +1     
  Lines       4471    4528     +57     
=======================================
+ Hits        3451    3506     +55     
- Misses       701     702      +1     
- Partials     319     320      +1     
Impacted Files Coverage Δ
operator/builtin/parser/keyvalue/keyvalue.go 100.0% <100.0%> (ø)
operator/builtin/input/tcp/tcp.go 78.0% <0.0%> (-1.7%) ⬇️

parsed := make(map[string]interface{})

var err error
for _, raw := range splitStringByWhitespace(input) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. The operator now takes a func(input string) []string for splitting the input string. By default, it will split on whitespace, if the user provides a character or substring, stirngs.Split() is used.

operator/builtin/parser/keyvalue/keyvalue.go Outdated Show resolved Hide resolved
Comment on lines 13 to 14
| `parse_from` | $ | A [field](/docs/types/field.md) that indicates the field to be parsed into key value pairs |
| `parse_to` | $ | A [field](/docs/types/field.md) that indicates the field to be parsed as into key value pairs |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The library technically still interprets $ as $body, but we've gotten away from documenting it this way. Better to be clear.


### Configuration Fields

| Field | Default | Description |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: To be consistent with other docs, can you add punctuation to the descriptions.

return &KVParserConfig{
ParserConfig: helper.NewParserConfig(operatorID, "key_value_parser"),
Delimiter: "=",
PairDelimiter: "",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PairDelimiter: "",

Since this is the zero value for any string, not needed unless it adds clarity, but I don't think it does.

key := cleanString(m[0])
value := cleanString(m[1])

// TODO: Check if key already exists and fail if so?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failing entirely seems harsh. Probably a lot better to get a partial log than none.

We could alternately log the error. Not sure the performance hit of checking every time is worth it for the rare case when it matters though.

Up to you, but we should decide and remove the TODO.

@@ -0,0 +1 @@
type: key_value_parser
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type: key_value_parser
type: key_value_parser

@@ -0,0 +1,2 @@
type: key_value_parser
delimiter: ";"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
delimiter: ";"
delimiter: ";"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not consistent on this in this library, but we need to move in that direction.

@djaglowski
Copy link
Member

Overall this looks good to me. Just a few minor cleanup things.

djaglowski and others added 7 commits March 28, 2022 14:55
This test is meant to ensure that partial logs are flushed
on an interval if they are not 'completed'. The test
appears to have too unforgiving a margin when ensuring that
the timeout is not applied too soon.
…pen-telemetry#356)

Bumps [github.com/onsi/gomega](https://github.com/onsi/gomega) from 1.17.0 to 1.18.0.
- [Release notes](https://github.com/onsi/gomega/releases)
- [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md)
- [Commits](onsi/gomega@v1.17.0...v1.18.0)

---
updated-dependencies:
- dependency-name: github.com/onsi/gomega
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [k8s.io/client-go](https://github.com/kubernetes/client-go) from 0.23.2 to 0.23.3.
- [Release notes](https://github.com/kubernetes/client-go/releases)
- [Changelog](https://github.com/kubernetes/client-go/blob/master/CHANGELOG.md)
- [Commits](kubernetes/client-go@v0.23.2...v0.23.3)

---
updated-dependencies:
- dependency-name: k8s.io/client-go
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…pen-telemetry#363)

Bumps [github.com/onsi/gomega](https://github.com/onsi/gomega) from 1.18.0 to 1.18.1.
- [Release notes](https://github.com/onsi/gomega/releases)
- [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md)
- [Commits](onsi/gomega@v1.18.0...v1.18.1)

---
updated-dependencies:
- dependency-name: github.com/onsi/gomega
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…try#361)

Bumps [go.opentelemetry.io/collector](https://github.com/open-telemetry/opentelemetry-collector) from 0.42.0 to 0.43.1.
- [Release notes](https://github.com/open-telemetry/opentelemetry-collector/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-collector/blob/main/CHANGELOG.md)
- [Commits](open-telemetry/opentelemetry-collector@v0.42.0...v0.43.1)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/collector
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…etry#362)

Bumps [github.com/golangci/golangci-lint](https://github.com/golangci/golangci-lint) from 1.43.0 to 1.44.0.
- [Release notes](https://github.com/golangci/golangci-lint/releases)
- [Changelog](https://github.com/golangci/golangci-lint/blob/master/CHANGELOG.md)
- [Commits](golangci/golangci-lint@v1.43.0...v1.44.0)

---
updated-dependencies:
- dependency-name: github.com/golangci/golangci-lint
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
dependabot bot and others added 28 commits March 28, 2022 14:56
)

Bumps [github.com/securego/gosec/v2](https://github.com/securego/gosec) from 2.9.6 to 2.10.0.
- [Release notes](https://github.com/securego/gosec/releases)
- [Changelog](https://github.com/securego/gosec/blob/master/.goreleaser.yml)
- [Commits](securego/gosec@v2.9.6...v2.10.0)

---
updated-dependencies:
- dependency-name: github.com/securego/gosec/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…hes line (open-telemetry#416)

* feat(operator/recombine): do not combine logs before first_entry matches line

Signed-off-by: Dominik Rosiek <[email protected]>
…try#422)

Bumps [go.opentelemetry.io/collector](https://github.com/open-telemetry/opentelemetry-collector) from 0.45.0 to 0.46.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-collector/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-collector/blob/main/CHANGELOG.md)
- [Commits](open-telemetry/opentelemetry-collector@v0.45.0...v0.46.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/collector
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Add support for parsing multiline csv records

The csv parser previously was unable to properly handle multiline values.
This change adds support. Newlines within csv records are preserved.
Several tools were required by this repo but not actually used.
This was a vestigial feature and can be removed without any impact.
* Bump gonum to resolve iteration issue in Go 1.18

* Update changelog for immediate patch
* Revert version of syslog-go

* chlog
)

Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.7.0 to 1.7.1.
- [Release notes](https://github.com/stretchr/testify/releases)
- [Commits](stretchr/testify@v1.7.0...v1.7.1)

---
updated-dependencies:
- dependency-name: github.com/stretchr/testify
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…etry#442)

Bumps [github.com/golangci/golangci-lint](https://github.com/golangci/golangci-lint) from 1.44.2 to 1.45.0.
- [Release notes](https://github.com/golangci/golangci-lint/releases)
- [Changelog](https://github.com/golangci/golangci-lint/blob/master/CHANGELOG.md)
- [Commits](golangci/golangci-lint@v1.44.2...v1.45.0)

---
updated-dependencies:
- dependency-name: github.com/golangci/golangci-lint
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…etry#434)

* feat(helpers/multiline): add test for flusher if multiple logs in buffer

Signed-off-by: Dominik Rosiek <[email protected]>

* refactor(helpers/multiline): refactor flusher due to bug

Signed-off-by: Dominik Rosiek <[email protected]>

* feat(helpers/multiline): add more tests and fixes for multiline

Signed-off-by: Dominik Rosiek <[email protected]>

* feat(helpers/multiline): add more tests and fixes for multiline

Signed-off-by: Dominik Rosiek <[email protected]>

* refactor(helpers/multiline): add flushed function to forceFlusher

Signed-off-by: Dominik Rosiek <[email protected]>

* refactor(helpers/multiline): wrap splitFuncs with force flusher splitFunc to simplify logic

Signed-off-by: Dominik Rosiek <[email protected]>

* tests(helpers/multiline): unify force flusher starting data length

Signed-off-by: Dominik Rosiek <[email protected]>

* feat(helpers/multiline): do not flush empty log

Signed-off-by: Dominik Rosiek <[email protected]>

* tests(helpers/multiline): do not overengineer tests

Signed-off-by: Dominik Rosiek <[email protected]>

* feat(helpers/multiline): remove enable force flushing

Signed-off-by: Dominik Rosiek <[email protected]>

* refactor(helpers/multiline): remove NewFlusher function

Signed-off-by: Dominik Rosiek <[email protected]>

* refactor(helpers/multiline): flatter flusherSplitFunc

Signed-off-by: Dominik Rosiek <[email protected]>

* refactor(helpers/multiline): extract force flusher related function from flusherSplitFunc

Signed-off-by: Dominik Rosiek <[email protected]>

* refactor(helpers/multiline): remove splitFuncWrapper

Signed-off-by: Dominik Rosiek <[email protected]>

* tests(helpers/multiline): do not return empty log for NewNewlineSplitFunc

Signed-off-by: Dominik Rosiek <[email protected]>

* chore(helpers/multiline): add comment

Signed-off-by: Dominik Rosiek <[email protected]>

* refactor(helpers/multiline): revert not necessary needed change

Signed-off-by: Dominik Rosiek <[email protected]>
* Remove '$' from field syntax

* Enforce rule that body fields must start with 'body'
This operator assumes that resource and attributes are flat maps.
The add operator has made it redundant anyways.
* Enforce maximum SD-NAME length of 32, per RFC5424

Longer SD-NAMEs were previously allowed in fork of go-syslog
dependency, but it is not clear that this is necessary.
…ry#430)

* Add changelog entry for major set of breaking changes.
…lace existing value in the rare case that it already exists
@jsirianni jsirianni closed this Mar 28, 2022
@jsirianni jsirianni deleted the kv-parser branch March 28, 2022 18:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants