Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -21,6 +21,9 @@ Increment the:
* [SDK] Implement env var configuration for PeriodicExportingMetricReader
[#3549](https://github.com/open-telemetry/opentelemetry-cpp/pull/3549)

* [SDK] Update default exemplar reservoir size for exponential histograms
[#3551](https://github.com/open-telemetry/opentelemetry-cpp/pull/3551)

## [1.22 2025-07-11]

* [DOC] Udpate link to membership document
Expand Down
21 changes: 20 additions & 1 deletion sdk/include/opentelemetry/sdk/metrics/exemplar/reservoir_utils.h
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