-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[pkg/ottl]: Add functions for parsing CSV #30921
Comments
Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
I'd like to take on adding these functions once we agree on design. |
In this situation the data was not collected by the filelogreceiver correct? I believe we could use Optional parameters to reduce the functionality to 1 function. I also think both delimiters could be Optional with a default value of |
Yes, this would be in a situation where the log is received and is not able to be parsed with operators in one of the stanza-based operators (e.g. receiving direct OTLP data with the otlp receiver). It's been a while since I've touched a lot of the OTTL stuff, I completely missed that there are optional parameters! Would it make sense for the signature to look something like this?
We could condense the
|
This would be my preference. Annoyingly functions can't specify their own enums yet, a it would be a string, similar to |
@evan-bradley please take a look at this proposal |
This all sounds good to me. |
@TylerHelmuth @evan-bradley I've opened a PR for adding the ParseCSV converter, when either of you get a chance to look! |
**Description:** * Adds a new ParseCSV converter that can parse CSV row strings. **Link to tracking Issue:** Closes #30921 **Testing:** * Unit tests * Manually tested the examples with a local build of the collector **Documentation:** * Adds documentation for using the ParseCSV converter.
**Description:** * Adds a new ParseCSV converter that can parse CSV row strings. **Link to tracking Issue:** Closes open-telemetry#30921 **Testing:** * Unit tests * Manually tested the examples with a local build of the collector **Documentation:** * Adds documentation for using the ParseCSV converter.
Component(s)
pkg/ottl, processor/transform
Is your feature request related to a problem? Please describe.
Currently, there is no equivalent to stanza's CSV parsing operator in OTTL.
I would like to be able to parse CSV with OTTL, instead of using the logtransformprocessor which is planned to be eventually removed.
Describe the solution you'd like
Add 3 converter functions:
where:
These functions all return a pcommon.Map struct that is the result of parsing the target string as CSV.
In terms of implementation, both
ParseCSV
andParseCSVLazyQuotes
will useencoding/csv
to parse CSV.ParseCSVIgnoreQuotes
will use strings.Split to parse. This is the same way that that the stanza package accomplishes CSV parsing.The difference between the three functions is that:
ParseCSV
will do typical CSV parsingParseCSVLazyQuotes
will parse with theLazyQuotes
option (see: https://pkg.go.dev/encoding/csv#Reader)ParseCSVIgnoreQuotes
will parse by completely ignoring quotes, just using strings.Split to split on the delimiterDescribe alternatives you've considered
ParseCSVIgnoreQuotes
might be similar enough toSplit
that we could consider removing it.What's nice about keeping this function is that it creates a map from the split, e.g.:
Turns into
And I don't think there's a currently a way to accomplish that column headers + row -< map operation currently, so I think it's still a valuable function.
Additional context
No response
The text was updated successfully, but these errors were encountered: