PMM-15248 oplatencies histogram. - #1329
Open
JiriCtvrtka wants to merge 14 commits into
Open
Conversation
Contributor
Author
|
@copilot review |
Contributor
I reviewed the current PR changes and didn’t find any high-confidence bugs, logic errors, or security issues. |
Contributor
Author
|
@copilot review |
Contributor
I re-reviewed the current PR diff and ran focused histogram/opLatencies tests; no high-confidence bugs, logic errors, or security issues were found. |
JiriCtvrtka
marked this pull request as ready for review
August 4, 2026 06:38
JiriCtvrtka
requested review from
ademidoff and
maxkondr
and removed request for
a team
August 4, 2026 06:38
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.
PMM-15248
Problem
On MongoDB 8.3 the exporter fails the scrape with
collected metric ... was collected before with the same name and label values(#1285).
serverStatus.opLatencies.<reads|writes|commands|transactions>exposes its latency buckets as ahistogramarray whose boundary field is namedmicros, notlowerBound:Bucket detection only accepted lowerBound, so these arrays were not recognized as buckets and each element was flattened into mongodb_ss_opLatencies_reads_histogram_micros and mongodb_ss_opLatencies_reads_histogram_count with identical names and labels — a duplicate series that the registry rejects.
The includeHistograms gate had a second, related problem: it matched on the path (histograms), so it could not see the new histogram node at all, and matching on histogram alone would drop every future node that happens to carry that name without holding buckets.
Fix
Recognize the bucket boundary under either lowerBound or micros (both documented as the lower bound of the bucket) and expose both shapes under the existing lower_bound label, so queries and dashboards do not have to know which shape the server used.
Gate includeHistograms on the bucket shape (an array of {bound, count} documents) instead of the node name, so opLatencies.histogram is skipped by default like the other buckets, while non-bucket nodes named histogram/histograms keep being collected. Fields next to the buckets (e.g. mongodb_ss_opLatencies_latency) are unaffected.
Resulting metric, with one series per bucket:
Tests
testdata/get_diagnostic_data_8.3.json — a getDiagnosticData reply captured from the MongoDB 8.3.2 instance of #1285, trimmed to serverStatus.opLatencies (the histogram arrays) and serverStatus.metrics.query (the histograms nodes), so both bucket shapes are covered by real server output. It is parsed with bson.UnmarshalExtJSON because encoding/json yields []any instead of primitive.A and would hide everything array shaped.
All histogram tests now gather through a pedantic registry, so duplicate series and inconsistent descriptors fail the test instead of the scrape, and they assert the captured bound/count pairs rather than just the bound set.
New cases: opLatencies buckets do not collide, are skipped by default, are not renamed or duplicated by compatibleMode / the v1 conversions (no op_type series on the buckets), and a non-bucket node named histogram is still collected.