6 #ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW
10 # include "opentelemetry/common/macros.h"
11 # include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h"
12 # include "opentelemetry/sdk/metrics/exemplar/aligned_histogram_bucket_exemplar_reservoir.h"
13 # include "opentelemetry/sdk/metrics/exemplar/simple_fixed_size_exemplar_reservoir.h"
14 # include "opentelemetry/version.h"
21 static inline MapAndResetCellType GetMapAndResetCellMethod(
22 const InstrumentDescriptor &instrument_descriptor)
26 return &ReservoirCell::GetAndResetLong;
29 return &ReservoirCell::GetAndResetDouble;
32 static inline size_t GetSimpleFixedReservoirDefaultSize(
const AggregationType agg_type,
33 const AggregationConfig *
const agg_config)
36 constexpr
size_t kMaxBase2ExponentialHistogramReservoirSize = 20;
40 const auto *histogram_agg_config =
41 static_cast<const Base2ExponentialHistogramAggregationConfig *
>(agg_config);
42 return (
std::min)(kMaxBase2ExponentialHistogramReservoirSize,
43 histogram_agg_config->max_buckets_);
46 return SimpleFixedSizeExemplarReservoir::kDefaultSimpleReservoirSize;
51 const AggregationConfig *agg_config,
52 const InstrumentDescriptor &instrument_descriptor)
56 const auto *histogram_agg_config =
static_cast<const HistogramAggregationConfig *
>(agg_config);
63 if (histogram_agg_config !=
nullptr && histogram_agg_config->boundaries_.size() > 1)
66 histogram_agg_config->boundaries_.size(),
67 AlignedHistogramBucketExemplarReservoir::GetHistogramCellSelector(
68 histogram_agg_config->boundaries_),
69 GetMapAndResetCellMethod(instrument_descriptor)));
74 GetSimpleFixedReservoirDefaultSize(agg_type, agg_config),
75 SimpleFixedSizeExemplarReservoir::GetSimpleFixedSizeCellSelector(),
76 GetMapAndResetCellMethod(instrument_descriptor)));
81 #endif // ENABLE_METRICS_EXEMPLAR_PREVIEW