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

[exporter/prometheusremotewrite] respect integer exemplar values #36688

Conversation

perebaj
Copy link
Contributor

@perebaj perebaj commented Dec 5, 2024

Description

Fixing when exemplars receive values that aren't doubles

Link to tracking issue

Fixes #36657

Comment on lines 215 to 216
// getHistogramDataPointWithExemplarsInt returns a HistogramDataPoint populating the exemplar with an int64 value.
func getHistogramDataPointWithExemplarsInt(t *testing.T, time time.Time, value int64, traceID string, spanID string, attributeKey string, attributeValue string) pmetric.HistogramDataPoint {
Copy link
Contributor Author

@perebaj perebaj Dec 5, 2024

Choose a reason for hiding this comment

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

I basically copy/paste the content of this function ⬇️

func getHistogramDataPointWithExemplars(t *testing.T, time time.Time, value float64, traceID string, spanID string, attributeKey string, attributeValue string) pmetric.HistogramDataPoint {

But changing the signature to receive an int64 value instead of a float64 one. Does this make sense?

I'm also added a comment in the top of the function, but I notice that most of the private functions doesn't have a comment, should I keep it?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe this is a good use case for generics?

func getHistogramDataPointWithExemplars[V int64 | float64](t *testing.T, time time.Time, value V, traceID string, spanID string, attributeKey string, attributeValue string) pmetric.HistogramDataPoint {
.
.
.
    switch V.(type) {
    case int64:
        e.SetIntValue(value)
    case float64:
        e.SetDoubleValue(value)
    }
.
.
.
}

We could avoid a little bit of code and the change is not thaaaat big to the original function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

7644383

I removed the new helper function that I created, and I added the generic that you mentioned in the existing function

@ArthurSens
Copy link
Member

Nice, the only thing left is a changelog entry. When doing a release of this project we compile all files located in this folder. You can copy one as an example, change it to represent what is being fixed in this PR, and commit :)

… github.com:perebaj/opentelemetry-collector-contrib into exporter/prometheusremotewriteexporter/exemplar-int
@perebaj
Copy link
Contributor Author

perebaj commented Dec 5, 2024

Hey guys @ArthurSens @dashpole, feel free to tag me in any kind of issue that you think would be interesting to solve

I'm open to help and learn more about this ecosystem! 🙃

@dashpole dashpole added the ready to merge Code review completed; ready to merge by maintainers label Dec 5, 2024
@evan-bradley evan-bradley removed the ready to merge Code review completed; ready to merge by maintainers label Dec 6, 2024
Copy link
Contributor

@evan-bradley evan-bradley left a comment

Choose a reason for hiding this comment

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

Thanks @perebaj!

@evan-bradley evan-bradley added the ready to merge Code review completed; ready to merge by maintainers label Dec 6, 2024
@evan-bradley evan-bradley merged commit 50630c4 into open-telemetry:main Dec 6, 2024
168 checks passed
@github-actions github-actions bot added this to the next release milestone Dec 6, 2024
ZenoCC-Peng pushed a commit to ZenoCC-Peng/opentelemetry-collector-contrib that referenced this pull request Dec 6, 2024
MovieStoreGuy pushed a commit that referenced this pull request Dec 11, 2024
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

As we change the gofmt by gofumpt ->
#36471,
the rewrite rule that is responsible for change `interface{}` by `any`
isn't working anymore. We noticed this problem here ->
#36688 (comment).
This PR tries to address this lack.
sbylica-splunk pushed a commit to sbylica-splunk/opentelemetry-collector-contrib that referenced this pull request Dec 17, 2024
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

As we change the gofmt by gofumpt ->
open-telemetry#36471,
the rewrite rule that is responsible for change `interface{}` by `any`
isn't working anymore. We noticed this problem here ->
open-telemetry#36688 (comment).
This PR tries to address this lack.
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.

Prometheus remote write does not respect integer exemplar values
5 participants