Skip to content
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: prom translation rw2 add support for labels #35751

Conversation

jmichalek132
Copy link
Contributor

@jmichalek132 jmichalek132 commented Oct 11, 2024

Description

Adding full support for handling labels.

Link to tracking issue #33661

Fixes

Testing

Documentation

@jmichalek132 jmichalek132 force-pushed the jm-prom-translation-rw2-add-support-for-labels branch from 2073e6e to 18665e9 Compare October 16, 2024 16:23
@jmichalek132 jmichalek132 force-pushed the jm-prom-translation-rw2-add-support-for-labels branch from 18665e9 to 8165501 Compare October 16, 2024 16:24
@jmichalek132 jmichalek132 force-pushed the jm-prom-translation-rw2-add-support-for-labels branch from 8165501 to 35413ab Compare October 16, 2024 16:25
Copy link
Member

@ArthurSens ArthurSens left a comment

Choose a reason for hiding this comment

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

It would be awesome if we could avoid copy-pasting code, and I think it is avoidable here.

Duplicated code increases cognitive load as we need to read 200 lines of code just to understand they do exactly the same thing. Duplicated code doesn't age well as we're all flawed humans with terrible memory and eventually make a change in one place and do not on in the other.

I know this would involve quite some work because we're relying on labels built-in functions for sorting and stuff, but could we refactor it to avoid duplicated code?

Copy link
Contributor

@aknuds1 aknuds1 left a comment

Choose a reason for hiding this comment

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

I really think you should try to minimize the code duplication as much as possible.

Could you take a look at my revision of your branch, where I remove the need for createAttributesV2 in the first place? I.e., I made your code work with prompb.Label instead to be compatible with the RW v1 code.

If you duplicate all the code between RW v1 and v2 it's going to be really painful to maintain.

@jmichalek132
Copy link
Contributor Author

I really think you should try to minimize the code duplication as much as possible.

Could you take a look at my revision of your branch, where I remove the need for createAttributesV2 in the first place? I.e., I made your code work with prompb.Label instead to be compatible with the RW v1 code.

If you duplicate all the code between RW v1 and v2 it's going to be really painful to maintain.

Thank you for the suggestion I will implement your suggested changes.

@jmichalek132 jmichalek132 marked this pull request as ready for review October 20, 2024 18:43
@jmichalek132 jmichalek132 requested a review from a team as a code owner October 20, 2024 18:43
Copy link
Member

@ArthurSens ArthurSens left a comment

Choose a reason for hiding this comment

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

Nice work, this is looking a lot better :)

Some extra comments. 👇

Signed-off-by: Juraj Michalek <[email protected]>
Copy link
Contributor

@aknuds1 aknuds1 left a comment

Choose a reason for hiding this comment

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

LGTM

@dashpole
Copy link
Contributor

Seems like CI was broken

 Error: elasticsearchexporter/bulkindexer_test.go:302:4: encoded-compare: use assert.JSONEq (testifylint)
			assert.Equal(t, "{\"create\":{\"_index\":\"foo\"}}\n{\"foo\": \"bar\"}\n", records[1].ContextMap()["request_body"])

Hopefully fixed by #35900

@dashpole dashpole added the ready to merge Code review completed; ready to merge by maintainers label Oct 21, 2024
@TylerHelmuth TylerHelmuth merged commit c5b6746 into open-telemetry:main Oct 23, 2024
167 of 168 checks passed
@github-actions github-actions bot added this to the next release milestone Oct 23, 2024
@jmichalek132 jmichalek132 deleted the jm-prom-translation-rw2-add-support-for-labels branch October 23, 2024 15:33
sbylica-splunk pushed a commit to sbylica-splunk/opentelemetry-collector-contrib that referenced this pull request Dec 17, 2024
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
Adding full support for handling labels.

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue open-telemetry#33661
Fixes

<!--Describe what testing was performed and which tests were added.-->
#### Testing

<!--Describe the documentation added.-->
#### Documentation

<!--Please delete paragraphs that you did not use before submitting.-->

---------

Signed-off-by: Juraj Michalek <[email protected]>
Co-authored-by: Arthur Silva Sens <[email protected]>
Co-authored-by: David Ashpole <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg/translator/prometheus ready to merge Code review completed; ready to merge by maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants