-
Notifications
You must be signed in to change notification settings - Fork 10
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
feat: Allow flattening of OTLP key-value lists #240
Conversation
@kentquirk @cartermp I've added an example options struct in 52c5529 to be passed into translate calls (trace and logs) that can control some of the behaviours you've pointed out as concerning (max depth, array & map flattening and body prefix). I think this has has two big benefits:
Note: this isn't complete, eg hasn't been added to public API calls yet, but shows the intention of the options |
I like the options pattern, but instead of passing around the options as an extra parameter on all these function calls, what do you think of the idea of making these functions be methods on a type that carries the options? It's not significantly more efficient from a performance standpoint but it neatly separates the function signatures and also helps organize the code a bit. |
Interesting - so create a version of the translator with these options set. I'll try it out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case it is useful, here is the flatten function we added recently for OTTL: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/ottl/ottlfuncs/func_flatten.go
75063a9
to
a7bfd96
Compare
a7bfd96
to
92c8d7c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Back to basics! This seems correct to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this simplified version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work.
Which problem is this PR solving?
When translating OTLP kv lists we currently just encode as a JSON string which isn't particularly useful. This PR extends the extraction behaviour to traverse kv lists to generate multiple event fields. The max depth is set to 5 levels.
For example, this kv attribute:
Previously would be stored like this:
After the change, the same kv list would be stored like this:
This change exposes the
AddAttributesToMap
func for consumers to use directly. This will be useful until metrics translation can be moved into this library (eg from shepherd).Short description of the changes
AddAttributesToMap
as a public function so consumers can use directlybody
field with a JSON string of the attribute to preserve backwards compatibility