forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[chore] prometheusremotewrite.FromMetrics: Fix createLabels closures …
…wrt. extra labels (open-telemetry#31635) **Description:** <Describe what has changed.> The functions for adding histogram and sum data points have a logic error in their `createLabels` closures. The two `createLabels` closures each take an optional "extras" slice, of label pairs. However, the loop logic doesn't advance to the next pair, just the first label value in fact, so if there were more than one extra pair (there isn't currently), there would be a bug. I'm refactoring the two `createLabels` closures into a free function by the same name, that loops correctly over `extras` arguments and handles if they are of uneven length (ignoring the unpaired `extra`). Also including a comprehensive test suite for `createLabels`. Marking the PR as a chore, since as described above, the logic error should currently not cause a bug. **Link to tracking Issue:** <Issue number if applicable> **Testing:** <Describe what testing was performed and which tests were added.> I've tested locally, there shouldn't be any practical changes since the `createLabels` closures are only called with one extra label pair at most. **Documentation:** <Describe the documentation added.> --------- Signed-off-by: Arve Knudsen <[email protected]>
- Loading branch information
Showing
2 changed files
with
121 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters