Skip to content

Base2ExponentialHistogramAggregation Merge fails with empty bucket aggregations #3424

@dbarker

Description

@dbarker

Describe your environment
main at 82ec2a5

Steps to reproduce

  1. Create a meter provider and add the PeriodicExportingMetricReader
  2. Create a view to change histogram aggregation to Base2ExponentialHistogramAggregation and add it to the provider
  3. Create a double histogram
  4. Record small values (ie: a nanosecond duration in units of seconds)

What is the expected behavior?
An exponential histogram is exported with valid scale and counts in buckets

What is the actual behavior?
Scale is reduced to unrealistic values (less than -10) and the histogram is corrupted.

Additional context
The temporal_metric_storage can merge the current aggregation into a default aggregation (default has zero counts and buckets are empty). See temporal_metric_storage.cc#L146.

When this happens the Base2ExponentialHistogramAggregation::Merge will reduce the scale incorrectly resulting in a corrupted histogram aggregation. This can happen when merging with any aggregation that has empty buckets (also the case if only zero values are aggregated).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage/acceptedIndicates an issue or PR is ready to be actively worked on.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions