opentelemetry-collector-contrib
opentelemetry-collector-contrib copied to clipboard
[exporter/prometheusremotewriteexporter] Fix a go panic
Description: Protect against a Go Panic when the bucket count collection is empty (observed with histograms coming from Micrometer 1.9.1
Fixes #12168 #12168
The committers listed above are authorized under a signed CLA.
- :white_check_mark: login: falken / name: Steven Nelson (29f4688b278229f72cfd46b17d8b366b525521dd)
Thanks for the fix! Please add a changelog entry https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#changelog
Added, hopefully correctly
The committers listed above are authorized under a signed CLA.
- :white_check_mark: login: falken / name: Steven Nelson (ac91e26958ae7e91fbf1d250158633f8e7bd389d)
Okay, @MovieStoreGuy I have added a test, and verified that the fix works, however I can't figure out what's wrong with the assertion.
I get:
helper_test.go:668:
Error Trace: /mnt/c/bench/dev/falken/opentelemetry-collector-contrib/pkg/translator/prometheusremotewrite/helper_test.go:668
Error: Not equal:
expected: map[string]*prompb.TimeSeries{"Histogram-__name__-foo_valid_Histogram_bucket-le-+Inf":(*prompb.TimeSeries)(0xc00028ea80), "Histogram-__name__-foo_valid_Histogram_count":(*prompb.TimeSeries)(0xc00028eaf0), "Histogram-__name__-foo_valid_Histogram_sum":(*prompb.TimeSeries)(0xc00028eb60)}
actual : map[string]*prompb.TimeSeries{"Histogram-__name__-foo_valid_Histogram_bucket-le-+Inf":(*prompb.TimeSeries)(0xc00028ecb0), "Histogram-__name__-foo_valid_Histogram_count":(*prompb.TimeSeries)(0xc00028ec40), "Histogram-__name__-foo_valid_Histogram_sum":(*prompb.TimeSeries)(0xc00028ebd0)}
Diff:
Test: Test_addSingleHistogramDataPoint/histogram_without_buckets
--- FAIL: Test_addSingleHistogramDataPoint (0.00s) --- FAIL: Test_addSingleHistogramDataPoint/histogram_without_buckets (0.00s)
I think you want to use assert.EqualValues instead of assert.Exactly since I suspect it is trying to enforce the same pointer address.
I think you want to use
assert.EqualValuesinstead ofassert.Exactlysince I suspect it is trying to enforce the same pointer address.
Both Exactly and EqualValues eventually use reflect.DeepEquals, which apparently returns false for the two maps.
@MovieStoreGuy Found the problem. Because the +Inf bucket has a value of NaN I can't compare them because NaN == NaN is false. I made the test explicitly test this case which should work.
@MovieStoreGuy Found the problem. Because the +Inf bucket has a value of NaN I can't compare them because NaN == NaN is false. I made the test explicitly test this case which should work.
I am glad you saw that because I did not.
Thank you for taking the time to fix this.
This PR was marked stale due to lack of activity. It will be closed in 14 days.
Apparently this is moot @Aneurysm9 @MovieStoreGuy since PR #12854
This PR was marked stale due to lack of activity. It will be closed in 14 days.
Closed as inactive. Feel free to reopen if this PR is still being worked on.