Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Increment the:
* [TEST] Shared otel-cpp libs linked to latest static protobuf and grpc
[#3544](https://github.com/open-telemetry/opentelemetry-cpp/pull/3544)

* [SDK] Set SimpleFixedSizeExemplarReservoir default size for exponential
histograms based on maximum bucket count

## [1.22 2025-07-11]

* [DOC] Udpate link to membership document
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW

# include <algorithm>

# include "opentelemetry/common/macros.h"
# include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h"
# include "opentelemetry/sdk/metrics/exemplar/aligned_histogram_bucket_exemplar_reservoir.h"
Expand All @@ -27,6 +29,23 @@ static inline MapAndResetCellType GetMapAndResetCellMethod(
return &ReservoirCell::GetAndResetDouble;
}

static inline size_t GetSimpleFixedReservoirDefaultSize(const AggregationType agg_type,
const AggregationConfig *const agg_config)

{
constexpr size_t kMaxBase2ExponentialHistogramReservoirSize = 20;

if (agg_type == AggregationType::kBase2ExponentialHistogram)
{
const auto *histogram_agg_config =
static_cast<const Base2ExponentialHistogramAggregationConfig *>(agg_config);
return (std::min)(kMaxBase2ExponentialHistogramReservoirSize,
histogram_agg_config->max_buckets_);
}

return SimpleFixedSizeExemplarReservoir::kDefaultSimpleReservoirSize;
}

static inline nostd::shared_ptr<ExemplarReservoir> GetExemplarReservoir(
const AggregationType agg_type,
const AggregationConfig *agg_config,
Expand All @@ -52,7 +71,7 @@ static inline nostd::shared_ptr<ExemplarReservoir> GetExemplarReservoir(
}

return nostd::shared_ptr<ExemplarReservoir>(new SimpleFixedSizeExemplarReservoir(
SimpleFixedSizeExemplarReservoir::kDefaultSimpleReservoirSize,
GetSimpleFixedReservoirDefaultSize(agg_type, agg_config),
SimpleFixedSizeExemplarReservoir::GetSimpleFixedSizeCellSelector(),
GetMapAndResetCellMethod(instrument_descriptor)));
}
Expand Down
Loading