opentelemetry: fix JSON histogram bounds handling - #11989
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe OTLP JSON histogram decoder gains a non-decreasing order check for explicit histogram bounds. A new C helper rejects null or out-of-order bounds arrays, an early-return error path frees temporary allocations on failure, and the ChangesHistogram bounds ordering validation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a1156599c8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| buckets, | ||
| metric_label_count, | ||
| (char **) metric_label_keys); | ||
| buckets = NULL; |
There was a problem hiding this comment.
Keep freeing buckets when create rejects arguments
When the JSON histogram has a valid bucket array but an empty metric name, cmt_histogram_create() returns NULL during its argument checks before it attaches or destroys the passed buckets; setting buckets = NULL unconditionally here skips the existing cleanup in the histogram == NULL path and leaks one bucket object per rejected request. Only transfer ownership after the call is known to have consumed the object, or free buckets on the pre-consumption failure path.
Useful? React with 👍 / 👎.
a115659 to
4ec5ede
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/opentelemetry/flb_opentelemetry_metrics.c`:
- Around line 1819-1822: The bounds validation in `check_histogram_bounds_order`
currently uses a greater-than comparison operator which allows equal adjacent
bounds to pass, but the OTLP specification requires bounds to be strictly
increasing. Modify the comparison operator in the bounds order validation
condition from greater-than to greater-than-or-equal to enforce strictly
increasing bounds and align with the OTLP proto contract specification, similar
to how `cmt_histogram_buckets_validate` implements this validation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 173654ec-ed91-4aa2-b010-f39bf72f4ae5
📒 Files selected for processing (2)
src/opentelemetry/flb_opentelemetry_metrics.ctests/integration/scenarios/in_opentelemetry/tests/test_in_opentelemetry_001.py
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
4ec5ede to
c7a1438
Compare
Problem
OTLP/HTTP JSON metrics can carry histogram
explicitBoundsthat are not monotonically non-decreasing. The JSON decoder passed those bounds into cmetrics before rejecting them, and then freed the bucket object again whencmt_histogram_create()returnedNULL.Changes
cmt_histogram_create()as consuming the buckets object once called, including internal failure paths.Validation
cmake --build build --target fluent-bit-bin -j 8tests/integration/.venv/bin/python -m pytest tests/integration/scenarios/in_opentelemetry/tests/test_in_opentelemetry_001.py::test_in_opentelemetry_rejects_json_histogram_with_descending_bounds -qVALGRIND=1 VALGRIND_STRICT=1 tests/integration/.venv/bin/python -m pytest tests/integration/scenarios/in_opentelemetry/tests/test_in_opentelemetry_001.py::test_in_opentelemetry_rejects_json_histogram_with_descending_bounds -qctest --test-dir build -R flb-it-opentelemetry --output-on-failureGITHUB_EVENT_NAME=pull_request GITHUB_BASE_REF=master tests/integration/.venv/bin/python .github/scripts/commit_prefix_check.pySummary by CodeRabbit
Release Notes
Bug Fixes
explicitBoundsthat are not in non-decreasing order, including degenerate or invalid bound sequences.Tests
explicitBoundsand acceptance of valid bounds, verifying stored datapoint values (including normalizedexplicitBounds).