Skip to content

[cumulativetodeltaprocessor] Add histogram_fields config for selective field conversion#49407

Open
Chau-Tran wants to merge 1 commit into
open-telemetry:mainfrom
Chau-Tran:feat/histogram-fields-filter
Open

[cumulativetodeltaprocessor] Add histogram_fields config for selective field conversion#49407
Chau-Tran wants to merge 1 commit into
open-telemetry:mainfrom
Chau-Tran:feat/histogram-fields-filter

Conversation

@Chau-Tran

Copy link
Copy Markdown

Description

Adds an optional histogram_fields allowlist to cumulativetodeltaprocessor. The list controls which histogram data-point fields (bucket_counts, sum, count) are converted to delta. When unset (default), all three fields are converted — identical to today's behavior.

When set, only the listed fields are written back from the tracker's delta value; the others keep their cumulative value on the emitted data point. The tracker itself still computes a full delta internally so state stays consistent across restarts, resets, and the existing bucket-mismatch handling — only the write-back to the data point is gated.

Applies to both Histogram and ExponentialHistogram. RemoveMin/RemoveMax continues to apply whenever any field converts (min/max can't be re-derived from a partial conversion). Reset / NaN / NoRecordedValue handling is unchanged.

processors:
  cumulativetodelta:
    include:
      metric_types: [histogram]
    histogram_fields: [bucket_counts]   # only buckets become delta; sum/count stay cumulative

Link to tracking issue

Fixes #48617

Testing

  • go test -race ./... passes in processor/cumulativetodeltaprocessor and its sub-packages.
  • make fmt lint passes (testifylint, gofmt, golangci-lint).
  • make chlog-validate passes.
  • New test cases (table-driven) cover: every single-field allowlist, every pairwise combination, all-three, the implicit empty-default, and a validation case for an unknown field name. Tests assert both that listed fields convert to delta and that unlisted fields retain their cumulative value across two data-point intervals.

Documentation

  • README.md: new bullet under "Configuration" describing histogram_fields, and an example YAML block showing the prototypical bucket_counts-only opt-in.
  • Changelog entry under .chloggen/.

…e field conversion

Add histogram_fields configuration option that specifies which histogram
fields to convert to delta temporality. Valid values: bucket_counts, sum,
count. When empty (default), all fields are converted (backward compatible).

This enables use cases where only bucket_counts should be converted to
delta (for native histogram storage) while sum and count remain cumulative
for RATE() queries.

Fixes open-telemetry#48617

Assisted-by: Claude Opus 4.6
Signed-off-by: Chau Tran <chau.tran@salesforce.com>
@Chau-Tran Chau-Tran requested review from a team and TylerHelmuth as code owners June 30, 2026 19:02
@linux-foundation-easycla

Copy link
Copy Markdown

CLA Missing ID

  • ❌ The email address for the commit (07a01e0) is not linked to the GitHub account, preventing the EasyCLA check. Consult this Help Article and GitHub Help to resolve. (To view the commit's email address, add .patch at the end of this PR page's URL.) For further assistance with EasyCLA, please visit our EasyCLA portal and chat with our support bot.

@github-actions github-actions Bot added the first-time contributor PRs made by new contributors label Jun 30, 2026
@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.
  • 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.
  • Give reviewers at least a few days before pinging them for feedback.
  • If you need help or struggle to move your PR forward:

@github-actions github-actions Bot added the processor/cumulativetodelta Cumulative To Delta processor label Jun 30, 2026
@TylerHelmuth

Copy link
Copy Markdown
Member

@Chau-Tran please sign the CLA and confirm to the PR template's attestation (the I am a human checkbox)

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 processor/cumulativetodelta Cumulative To Delta processor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[cumulativetodeltaprocessor] Add histogram_fields config for selective field conversion

3 participants