5
5
6
6
#ifdef ENABLE_METRICS_EXEMPLAR_PREVIEW
7
7
8
+ # include < algorithm>
9
+
8
10
# include " opentelemetry/common/macros.h"
9
11
# include " opentelemetry/sdk/metrics/aggregation/aggregation_config.h"
10
12
# include " opentelemetry/sdk/metrics/exemplar/aligned_histogram_bucket_exemplar_reservoir.h"
@@ -27,6 +29,23 @@ static inline MapAndResetCellType GetMapAndResetCellMethod(
27
29
return &ReservoirCell::GetAndResetDouble;
28
30
}
29
31
32
+ static inline size_t GetSimpleFixedReservoirDefaultSize (const AggregationType agg_type,
33
+ const AggregationConfig *const agg_config)
34
+
35
+ {
36
+ constexpr size_t kMaxBase2ExponentialHistogramReservoirSize = 20 ;
37
+
38
+ if (agg_type == AggregationType::kBase2ExponentialHistogram )
39
+ {
40
+ const auto *histogram_agg_config =
41
+ static_cast <const Base2ExponentialHistogramAggregationConfig *>(agg_config);
42
+ return (std::min)(kMaxBase2ExponentialHistogramReservoirSize ,
43
+ histogram_agg_config->max_buckets_ );
44
+ }
45
+
46
+ return SimpleFixedSizeExemplarReservoir::kDefaultSimpleReservoirSize ;
47
+ }
48
+
30
49
static inline nostd::shared_ptr<ExemplarReservoir> GetExemplarReservoir (
31
50
const AggregationType agg_type,
32
51
const AggregationConfig *agg_config,
@@ -52,7 +71,7 @@ static inline nostd::shared_ptr<ExemplarReservoir> GetExemplarReservoir(
52
71
}
53
72
54
73
return nostd::shared_ptr<ExemplarReservoir>(new SimpleFixedSizeExemplarReservoir (
55
- SimpleFixedSizeExemplarReservoir:: kDefaultSimpleReservoirSize ,
74
+ GetSimpleFixedReservoirDefaultSize (agg_type, agg_config) ,
56
75
SimpleFixedSizeExemplarReservoir::GetSimpleFixedSizeCellSelector (),
57
76
GetMapAndResetCellMethod (instrument_descriptor)));
58
77
}
0 commit comments