-
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
[processor/attributesprocessor] Add a convert action #7930
[processor/attributesprocessor] Add a convert action #7930
Conversation
Thank you for the contribution @hughsimpson! On the terminology part - I think that |
@bogdandrutu @anuraaga @jpkrohling how does it relate to |
@hughsimpson did another run and added few comments. Also, seems some checks are failing |
Pushed a merge because the bot said this issue was stale... 🤷 Any chance of a review from @dashpole or @dmitryax at some point? Is there something I've missed? I don't mind tidying the commit history or whatever... Edit: oh, well I see that the release notes need updating, at least. I'm many releases behind on that front now. Will push |
@@ -87,8 +88,14 @@ func generateMetricData(resourceName string, attrs map[string]pdata.AttributeVal | |||
pdata.NewAttributeMapFromMap(attrs).CopyTo(dps.At(i).Attributes()) | |||
dps.At(i).Attributes().Sort() | |||
} | |||
default: |
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.
Tbqh this entire switch block is redundant but I'm leaving it in for now to reduce churn on the pr
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 am not sure why it is needed. Also, removing this block and uncommenting the test cases where you found issues leads to green tests :)
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.
That's because the tests didn't previously actually test anything. If you changed the expected attributes randomly they still passed (I noticed this because I had a typo in one of my tests but it still passed). This is because generateMetricData
always returned a single None type metric with no attributes, so both the input and output generated the same empty data. If you would prefer, I could leave the tests as they are, but that felt kinda negligent to me
Since there's now a ticket and pr to track the issues with the metrics attributesprocessor, I've reverted the test fixes in the hope that it can facilitate the process of this pr getting merged |
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.
Overall LGTM, just couple nits
Co-authored-by: Dmitrii Anoshin <[email protected]>
Once @dmitryax approves, I'll merge this one. |
@dmitryax please tell me this can get over the line now 😅 |
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.
LGTM. just couple of nits
9f0b64c
to
0f296a1
Compare
@jpkrohling Think everything has been addressed now 🙏 |
Description:
The attributes processor doesn't currently have support for type conversions. This can be necessary for 3rd parties that expect fields to be of a certain type (e.g. http.status_code might be received as a string but required to be an int by a service provider). This pr adds a
convert
action to the attributesprocessor, which would look like:Only very naive conversions have been included for now. There's no obvious behaviour for converting non-numeric types to numeric types (with the exception of numeric strings). For example, should
[ 2 ]
be 1 (length of array) or 2 (only value of singleton array)? Given that, all non-obvious values areconverted to the zero valueleft unamended for nowTesting:
Tests added to the attribute processor for config and behaviour
Documentation:
Some copy has been added to the attributesprocessor readme to cover the new action type