Skip to content

[receiver/prometheusreceiver] Preserve bucketless histograms during NHCB conversion - #49892

Open
shubhgupta2104 wants to merge 8 commits into
open-telemetry:mainfrom
shubhgupta2104:fix-prometheusreceiver-bucketless-nhcb
Open

[receiver/prometheusreceiver] Preserve bucketless histograms during NHCB conversion#49892
shubhgupta2104 wants to merge 8 commits into
open-telemetry:mainfrom
shubhgupta2104:fix-prometheusreceiver-bucketless-nhcb

Conversation

@shubhgupta2104

@shubhgupta2104 shubhgupta2104 commented Jul 28, 2026

Copy link
Copy Markdown

Assisted-by Github-Copilot

Description

Bucketless classic histograms contain _sum and _count series but no _bucket series.

When convert_classic_histograms_to_nhcb: true is enabled and classic histogram retention is disabled, Prometheus converts these histograms into an NHCB with empty CustomValues and a single implicit +Inf bucket. The receiver currently returns early for this representation, silently dropping the histogram.

This change preserves the implicit +Inf bucket, consistent with the behaviour established in #22070 and #23448.

There are no configuration or public API changes.

Link to tracking issue

Fixes #49893

Related to #22070, #23448 , and #43095 .

Testing

Added receiver tests covering:

  • Integer histogram values
  • Floating-point histogram values
  • Stale histogram samples
  • Complete receiver scrape behavior

Documentation

Added a user-facing changelog entry describing the fix.

Authorship

  • I, a human, wrote this pull request description myself.

@linux-foundation-easycla

linux-foundation-easycla Bot commented Jul 28, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: shubhgupta2104 / name: Shubh Gupta (1dc8722)

@github-actions

Copy link
Copy Markdown
Contributor

Welcome, contributor! Thank you for your contribution to opentelemetry-collector-contrib.

Important reminders:

  • Read our Contributing Guidelines.
  • Sign the CLA if you haven't already.
  • Follow the OpenTelemetry Generative AI policy: disclose any AI use in your contribution, and communicate (PR descriptions, review replies) in your own words rather than AI-generated text.
  • Give reviewers at least a few days before pinging them for feedback.
  • If you need help with general setup, development process, or contributor etiquette, ask in #opentelemetry-new-contributors.
  • First-time contributors should have at most one PR not marked as draft until their first PR is merged.
  • If your change isn't one of our priority components, reviews may take more time.
  • Raise technical or Collector-specific questions in #otel-collector-dev or a Collector SIG meeting.

@github-actions github-actions Bot added the first-time contributor PRs made by new contributors label Jul 28, 2026
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Jul 28, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on the author · refreshed 2026-08-02 18:42 UTC

Respond to 1 review item (e.g. link a commit, explain why not, ask a follow-up):

  • Top-level threads: 1
Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Should this be with reviewers? Comment /dashboard route:reviewers to route it to them.
  • Anything wrong — including the routing? Report it with what you expected; it helps us improve the dashboard.

@shubhgupta2104
shubhgupta2104 marked this pull request as ready for review July 28, 2026 04:47
@shubhgupta2104
shubhgupta2104 requested review from a team, ArthurSens and dashpole as code owners July 28, 2026 04:47
@github-actions github-actions Bot added the receiver/prometheus Prometheus receiver label Jul 28, 2026
@github-actions
github-actions Bot requested review from Aneurysm9 and krajorama July 28, 2026 04:47
@shubhgupta2104

Copy link
Copy Markdown
Author

I found in a follow-up review that the fix also starts emitting semantically inconsistent _sum-only histogram families.

For example, a histogram containing _sum=123.5 but no _count can now become:

count=0
sum=123.5
buckets [0]

That is semantically questionable and differs from the classic path, which drops it. Prometheus’s conversion loses whether _count was absent, so fixing this cleanly may require more than checking Count == 0

Can you help me understand:

  • Should the receiver faithfully preserve Prometheus’s converted NHCB?
  • Or should it reject the semantically inconsistent count=0, sum!=0 case?

* Added retention-on/off E2E coverage, asserting one vs. two histogram representations.
* Added float stale-NHCB coverage.
* Clarified the changelog’s retention condition.

Left sum-only semantics, stale routing, and remote-write behavior for maintainer-approved follow-ups.
Validation passed: receiver tests, go vet, make lint, changelog validation, and diff checks. mint build is inapplicable because this is not a Multiproduct repository.

@dashpole dashpole left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks correct to me. @krajorama should take a look as well

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes a regression in the Prometheus receiver’s classic-histogram → NHCB conversion path where “bucketless” classic histograms (only _sum/_count, no _bucket series) could be silently dropped. The change aligns NHCB conversion behavior with the existing classic-histogram handling established in prior work (#22070 / #23448), preserving the implicit +Inf bucket representation instead of returning early.

Changes:

  • Stop treating NHCB histograms with empty CustomValues (no explicit bounds) as “unsupported” in toDistributionPoint, so bucketless histograms are still emitted.
  • Add unit and end-to-end receiver tests covering integer/float NHCB bucketless histograms, including stale samples and scrape behavior when classic retention is toggled.
  • Add a user-facing changelog entry describing the bug fix.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
receiver/prometheusreceiver/internal/metricfamily.go Removes early-return behavior that dropped NHCB bucketless histograms during conversion to OTLP histograms.
receiver/prometheusreceiver/internal/metricfamily_test.go Adds NHCB unit tests for empty explicit bounds (bucketless) for both integer and float histograms, including stale cases.
receiver/prometheusreceiver/metrics_receiver_test.go Adds an end-to-end scrape test ensuring bucketless classic histograms are preserved when converted to NHCB (with/without classic retention).
.chloggen/fix-prometheusreceiver-bucketless-nhcb.yaml Adds a changelog entry documenting the fix for users.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@shubhgupta2104

Copy link
Copy Markdown
Author

@dashpole I think you will need to click Approve and run workflow again, because I added a merge commit. Also, any thoughts on my comment above?

@singhvibhanshu

Copy link
Copy Markdown
Member

/workflow-approve

@dashpole

Copy link
Copy Markdown
Contributor
  • Should the receiver faithfully preserve Prometheus’s converted NHCB?
  • Or should it reject the semantically inconsistent count=0, sum!=0 case?

It should be consistent with the behavior in the classic path. So if it is rejected in that case, i'm OK with rejecting it here as well.

shubhgupta2104 and others added 2 commits August 1, 2026 05:45
Keep NHCB conversion consistent with the classic path by dropping
non-stale histograms with a zero count and nonzero sum.

Cover integer, float, and scrape paths while preserving valid
zero-count and stale histograms.

Assisted-by: GitHub Copilot
@singhvibhanshu

Copy link
Copy Markdown
Member

/workflow-approve

@shubhgupta2104

Copy link
Copy Markdown
Author

@krajorama Can you also take a look please? Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

first-time contributor PRs made by new contributors receiver/prometheus Prometheus receiver

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[receiver/prometheusreceiver] Classic histograms with only _sum/_count are dropped when convert_classic_histograms_to_nhcb is enabled

4 participants