Skip to content

lib: cmetrics: upgrade to v2.0.6#11681

Closed
edsiper wants to merge 1 commit into
masterfrom
cmetrics-2.0.6
Closed

lib: cmetrics: upgrade to v2.0.6#11681
edsiper wants to merge 1 commit into
masterfrom
cmetrics-2.0.6

Conversation

@edsiper

@edsiper edsiper commented Apr 8, 2026

Copy link
Copy Markdown
Member

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced Prometheus histogram validation to properly detect missing required labels and report syntax errors.
    • Fixed histogram concatenation behavior for aggregation type handling.
  • Chores

    • Version updated to 2.0.6.
    • Removed metric unit field support from message serialization.

Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
@coderabbitai

coderabbitai Bot commented Apr 8, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The PR updates CMetrics library version from 2.1.1 to 2.0.6, removes unit field serialization from msgpack codec operations, removes aggregation type assignment during exponential histogram concatenation, and adds explicit validation for the required "le" label in Prometheus histogram metrics while removing related tests.

Changes

Cohort / File(s) Summary
Version Update
lib/cmetrics/CMakeLists.txt
Updated CMT_VERSION_MINOR from 1 to 0 and CMT_VERSION_PATCH from 1 to 6, resulting in version string change from 2.1.1 to 2.0.6.
MessagePack Codec
lib/cmetrics/src/cmt_encode_msgpack.c, lib/cmetrics/src/cmt_decode_msgpack.c
Removed unit field from msgpack serialization and deserialization; refactored option unpacking to pass struct cmt_opts* directly instead of using struct cmt_map* as indirection, eliminating the unit option decoding path.
Prometheus Histogram Parsing
lib/cmetrics/src/cmt_decode_prometheus.c
Added explicit validation that histogram metrics include the required "le" label; now scans labels to verify presence and errors out with syntax error if missing, replacing implicit assumptions about label count.
Histogram Concatenation
lib/cmetrics/src/cmt_cat.c
Removed assignment of eh->aggregation_type when concatenating exponential histograms from source to destination.
Test Removals - Unit Field
lib/cmetrics/tests/encoding.c, lib/cmetrics/tests/opentelemetry.c
Deleted msgpack unit field roundtrip test and removed unit-related assertions from OpenTelemetry test; removed unit assignment in OpenTelemetry test data generation.
Test Removals - Aggregation Type
lib/cmetrics/tests/cat.c
Removed test_exp_histogram_preserves_aggregation_type test case that verified aggregation type preservation during histogram concatenation.
Test Addition - Prometheus Validation
lib/cmetrics/tests/prometheus_parser.c
Added new negative test case test_histogram_missing_le_label to verify parser correctly rejects histograms with missing "le" label.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • cosmo0920

Poem

🐰 The unit field hops away so free,
Validation checks now clearly see,
Where le labels must always be,
Version bounds leap to 2.0.6 with glee! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'lib: cmetrics: upgrade to v2.0.6' accurately and concisely describes the main change—updating the CMetrics library to version 2.0.6, as confirmed by version number changes in CMakeLists.txt and the PR objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cmetrics-2.0.6

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0dd3a4e162

ℹ️ 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".

/* 'opts' */
mpack_write_cstr(writer, "opts");
mpack_start_map(writer, 5);
mpack_start_map(writer, 4);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Serialize metric unit in msgpack headers

Reducing the opts map to 4 fields here drops unit from msgpack output, so units are lost across the encode/decode path. Fluent Bit persists metrics through cmt_encode_msgpack_create/cmt_decode_msgpack_create, and exporters later consume map->unit (for example OTLP and Prometheus remote write metadata), so inputs that set units will now emit empty units after passing through a chunk. Please keep unit in the serialized header to preserve metric metadata.

Useful? React with 👍 / 👎.

Comment on lines 948 to 949
if (filtered_map != NULL) {
ret = cmt_cat_copy_map(&eh->opts, eh->map, filtered_map);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve exp histogram aggregation type in cmt_cat

When concatenating exponential histograms, this path no longer copies exp_histogram->aggregation_type into the destination object. A newly created eh is zero-initialized, so DELTA/CUMULATIVE inputs become UNSPECIFIED after cmt_cat(), and OTLP encoding then derives the wrong aggregation temporality from that field. Any workflow that merges contexts via cmt_cat can therefore emit incorrect exponential histogram semantics.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
lib/cmetrics/src/cmt_encode_msgpack.c (1)

96-115: ⚠️ Potential issue | 🔴 Critical

Breaking msgpack schema change: opts map reduced from 5 to 4 fields removes backward compatibility with v2.1.0 payloads.

The opts map was extended in v2.1.0 to include a unit field (5 fields total), but the current version reverts to 4 fields (ns, ss, name, desc). The decoder uses strict field validation: it returns CMT_MPACK_UNEXPECTED_KEY_ERROR when encountering unknown keys. This means payloads from v2.1.0 containing the unit field will fail to decode, causing data processing failures. There is no fallback mechanism or version handling to support both formats.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/cmetrics/src/cmt_encode_msgpack.c` around lines 96 - 115, The opts map
was reduced to 4 entries breaking compatibility with v2.1.0 which included a
unit field; restore the original 5-field schema by changing
mpack_start_map(writer, 4) to mpack_start_map(writer, 5) and insert code to
write the unit key/value (use mpack_write_cstr(writer, "unit");
mpack_write_cstr(writer, opts->unit);) between the other opts fields before
mpack_finish_map(writer) so encoders produce the expected 'unit' field that the
strict decoder requires.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/cmetrics/CMakeLists.txt`:
- Around line 7-9: The CMake variables CMT_VERSION_MAJOR, CMT_VERSION_MINOR, and
CMT_VERSION_PATCH were changed from 2.1.1 to 2.0.6 but the commit message says
"upgrade", creating an inconsistency; either correct the version numbers back to
the intended 2.1.1 values in the CMakeLists
(CMT_VERSION_MAJOR/CMT_VERSION_MINOR/CMT_VERSION_PATCH) or, if the downgrade to
2.0.6 is intentional, update the commit message to clearly state this is a
revert/downgrade to v2.0.6 (or add a note explaining why) so version change and
commit message align.

---

Outside diff comments:
In `@lib/cmetrics/src/cmt_encode_msgpack.c`:
- Around line 96-115: The opts map was reduced to 4 entries breaking
compatibility with v2.1.0 which included a unit field; restore the original
5-field schema by changing mpack_start_map(writer, 4) to mpack_start_map(writer,
5) and insert code to write the unit key/value (use mpack_write_cstr(writer,
"unit"); mpack_write_cstr(writer, opts->unit);) between the other opts fields
before mpack_finish_map(writer) so encoders produce the expected 'unit' field
that the strict decoder requires.
🪄 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: 05825072-e75d-4bea-8907-61572b1a87e9

📥 Commits

Reviewing files that changed from the base of the PR and between e0b99b6 and 0dd3a4e.

⛔ Files ignored due to path filters (1)
  • lib/cmetrics/tests/prometheus_remote_write_payload.bin is excluded by !**/*.bin
📒 Files selected for processing (9)
  • lib/cmetrics/CMakeLists.txt
  • lib/cmetrics/src/cmt_cat.c
  • lib/cmetrics/src/cmt_decode_msgpack.c
  • lib/cmetrics/src/cmt_decode_prometheus.c
  • lib/cmetrics/src/cmt_encode_msgpack.c
  • lib/cmetrics/tests/cat.c
  • lib/cmetrics/tests/encoding.c
  • lib/cmetrics/tests/opentelemetry.c
  • lib/cmetrics/tests/prometheus_parser.c
💤 Files with no reviewable changes (4)
  • lib/cmetrics/src/cmt_cat.c
  • lib/cmetrics/tests/cat.c
  • lib/cmetrics/tests/opentelemetry.c
  • lib/cmetrics/tests/encoding.c

Comment on lines 7 to +9
set(CMT_VERSION_MAJOR 2)
set(CMT_VERSION_MINOR 1)
set(CMT_VERSION_PATCH 1)
set(CMT_VERSION_MINOR 0)
set(CMT_VERSION_PATCH 6)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if there are any references to the expected version in the repository
echo "Checking for version references in the cmetrics library..."
rg -n "2\.1\.1|2\.0\.6" lib/cmetrics/ --type-add 'cmake:*.cmake' --type cmake --type-add 'txt:*.txt' --type txt -g '!build*'

Repository: fluent/fluent-bit

Length of output: 119


🏁 Script executed:

# Search for CMT_VERSION in all CMakeLists.txt files to understand version management
echo "=== Searching for CMT_VERSION definitions across the repo ==="
find . -name "CMakeLists.txt" -type f | head -20 | xargs grep -n "CMT_VERSION" 2>/dev/null || echo "No matches found"

echo ""
echo "=== Checking for version files or headers ==="
fd -e h -e c -e txt "version" --max-results 20 | head -20

echo ""
echo "=== Looking at the specific file context ==="
head -20 lib/cmetrics/CMakeLists.txt

Repository: fluent/fluent-bit

Length of output: 2001


🏁 Script executed:

# Check git history for this specific file to see version changes
echo "=== Git history for CMakeLists.txt version changes ==="
git log -p --follow -S "CMT_VERSION" -- lib/cmetrics/CMakeLists.txt 2>/dev/null | head -100

echo ""
echo "=== Alternative: Check recent git log for this file ==="
git log --oneline -10 -- lib/cmetrics/CMakeLists.txt 2>/dev/null

echo ""
echo "=== Check git diff for staged/recent changes to this file ==="
git diff -- lib/cmetrics/CMakeLists.txt 2>/dev/null || echo "No unstaged changes"

Repository: fluent/fluent-bit

Length of output: 277


🏁 Script executed:

# Get more detailed git history to see the version before the upgrade
echo "=== Show the commit content ==="
git show 0dd3a4e1:lib/cmetrics/CMakeLists.txt 2>/dev/null | head -15

echo ""
echo "=== Show previous version by checking parent commit ==="
git show 0dd3a4e1^:lib/cmetrics/CMakeLists.txt 2>/dev/null | head -15 || git log --reverse --all --oneline -- lib/cmetrics/CMakeLists.txt 2>/dev/null | head -5

Repository: fluent/fluent-bit

Length of output: 569


🏁 Script executed:

# Get the commit before 0dd3a4e1 to see the previous version
echo "=== Show parent commit version ==="
git show 0dd3a4e1~1:lib/cmetrics/CMakeLists.txt 2>/dev/null | head -15

echo ""
echo "=== Check if there's a version tag or release info ==="
git tag -l "*2.0.6*" "*2.1.1*" 2>/dev/null

echo ""
echo "=== Look at commit message ==="
git log -1 --format=fuller 0dd3a4e1 2>/dev/null

Repository: fluent/fluent-bit

Length of output: 521


🏁 Script executed:

# Try to get the actual diff to see what changed
echo "=== Get the actual diff for the version lines ==="
git show 0dd3a4e1 -- lib/cmetrics/CMakeLists.txt 2>/dev/null | grep -A 5 -B 5 "CMT_VERSION"

echo ""
echo "=== Check all commits that touched this file ==="
git log --oneline --all -- lib/cmetrics/CMakeLists.txt 2>/dev/null | head -10

echo ""
echo "=== Get previous commit's full CMakeLists.txt ==="
git log --all --oneline -p -- lib/cmetrics/CMakeLists.txt 2>/dev/null | head -80

Repository: fluent/fluent-bit

Length of output: 5231


Commit message inconsistency: says "upgrade" but version downgrade is from 2.1.1 to 2.0.6.

Git history shows the previous version was 2.1.1 (commit 83d7619), and this commit (0dd3a4e) sets version 2.0.6, which is a downgrade. The commit message states "upgrade to v2.0.6", which is misleading. If this is intentional (e.g., reverting to a stable release), the commit message should be clarified to reflect that. Otherwise, verify that the version numbers are correct.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/cmetrics/CMakeLists.txt` around lines 7 - 9, The CMake variables
CMT_VERSION_MAJOR, CMT_VERSION_MINOR, and CMT_VERSION_PATCH were changed from
2.1.1 to 2.0.6 but the commit message says "upgrade", creating an inconsistency;
either correct the version numbers back to the intended 2.1.1 values in the
CMakeLists (CMT_VERSION_MAJOR/CMT_VERSION_MINOR/CMT_VERSION_PATCH) or, if the
downgrade to 2.0.6 is intentional, update the commit message to clearly state
this is a revert/downgrade to v2.0.6 (or add a note explaining why) so version
change and commit message align.

@edsiper

edsiper commented Apr 8, 2026

Copy link
Copy Markdown
Member Author

PR replaced by #11685

@edsiper edsiper closed this Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant