fix: preserve histogram/exp_histogram temporality across msgpack round-trip#279
Open
truongnht wants to merge 1 commit into
Open
fix: preserve histogram/exp_histogram temporality across msgpack round-trip#279truongnht wants to merge 1 commit into
truongnht wants to merge 1 commit into
Conversation
…d-trip pack_header() in cmt_encode_msgpack.c only wrote the "aggregation_type" meta field for CMT_COUNTER. Histograms and exp_histograms encoded to msgpack and decoded back always ended up with CMT_AGGREGATION_TYPE_UNSPECIFIED regardless of the temporality they were created with, since cmt_decode_msgpack.c's unpack_basic_type_meta() never applied the decoded aggregation_type to those two types either. This is the exact path Fluent Bit's OTLP pipeline uses internally (in_opentelemetry decodes OTLP into cmetrics, buffers as msgpack, then out_opentelemetry re-encodes to OTLP). Any OTLP histogram with delta or cumulative temporality passing through Fluent Bit lost that metadata and downstream OTLP receivers (e.g. Prometheus with otlp-deltatocumulative) rejected it with "invalid temporality and type combination". Mirrors the existing CMT_COUNTER handling for CMT_HISTOGRAM and CMT_EXP_HISTOGRAM on both the encode and decode side. Adds tests/msgpack_temporality.c: a msgpack round-trip regression test for histogram, exp_histogram and counter aggregation_type. Verified this test fails on histogram/exp_histogram (counter passes) without the fix, and passes for all three with it. Signed-off-by: Truong Nguyen <truong.nguyen_1@philips.com>
7aabe41 to
bb60c7b
Compare
6 tasks
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #278
Summary
pack_header()incmt_encode_msgpack.conly writes theaggregation_typemeta field forCMT_COUNTER. Histograms and exp_histograms encoded to msgpack and decoded back always end up withCMT_AGGREGATION_TYPE_UNSPECIFIED, regardless of the temporality (delta/cumulative) they were created with — becauseunpack_basic_type_meta()incmt_decode_msgpack.cnever applies the decodedaggregation_typeback onto those two types either.This fix mirrors the existing
CMT_COUNTERhandling forCMT_HISTOGRAMandCMT_EXP_HISTOGRAM, on both the encode and decode side.Real-world impact
This is the exact code path Fluent Bit's OTLP pipeline uses internally:
Any OTLP histogram with delta or cumulative temporality passing through Fluent Bit loses that metadata in the msgpack round-trip. Downstream OTLP receivers that validate temporality (e.g. Prometheus with
otlp-deltatocumulativeenabled) reject the metric:Root cause, traced with evidence
cmt_decode_opentelemetry.c/cmt_encode_opentelemetry.c(the direct OTLP codec) correctly round-tripaggregation_typefor histograms — confirmed by reading the source.cmt_encode_msgpack.c/cmt_decode_msgpack.c(the internal msgpack codec Fluent Bit uses for its input/output plugin boundary) do not — confirmed by reading the source and reproducing locally.lib/cmetricscopy, deployed it in place of the stock image, ran a k6 OTLP load test through the same Fluent Bit pipeline, and confirmed via direct Prometheus API query thatk6_http_req_duration_milliseconds_bucket/_count/_sum(previously rejected) now land correctly with real data.Test plan
Added
tests/msgpack_temporality.c: round-trips a histogram, an exp_histogram, and a counter (as a control) throughcmt_encode_msgpack_create→cmt_decode_msgpack_createand assertsaggregation_typesurvives.ctestpasses: 18/18 (17 pre-existing + this new test), no regressionssrc/cmt_encode_msgpack.c/src/cmt_decode_msgpack.conly — confirms the test actually exercises the bug