|
1 | 1 | // Copyright The OpenTelemetry Authors
|
2 | 2 | // SPDX-License-Identifier: Apache-2.0
|
3 | 3 |
|
| 4 | +#include <cmath> |
| 5 | +#include <iostream> |
| 6 | +#include <limits> |
| 7 | + |
4 | 8 | #include "opentelemetry/sdk/metrics/aggregation/base2_exponential_histogram_aggregation.h"
|
5 |
| -#include "opentelemetry/sdk/metrics/aggregation/aggregation.h" |
6 | 9 | #include "opentelemetry/sdk/metrics/data/circular_buffer.h"
|
7 | 10 | #include "opentelemetry/sdk/metrics/data/point_data.h"
|
8 | 11 | #include "opentelemetry/version.h"
|
9 | 12 |
|
10 |
| -#include <cmath> |
11 |
| -#include <cstddef> |
12 |
| -#include <exception> |
13 |
| -#include <limits> |
14 |
| -#include <memory> |
15 |
| -#include <mutex> |
16 |
| - |
17 |
| -#include <iostream> |
18 |
| - |
19 | 13 | OPENTELEMETRY_BEGIN_NAMESPACE
|
20 | 14 | namespace sdk
|
21 | 15 | {
|
@@ -46,8 +40,8 @@ uint32_t GetScaleReduction(int32_t start_index, int32_t end_index, size_t max_bu
|
46 | 40 | // {
|
47 | 41 | // return 0;
|
48 | 42 | // }
|
49 |
| -// const int32_t start_index = std::min(first.StartIndex(), second.StartIndex()); |
50 |
| -// const int32_t end_index = std::max(first.EndIndex(), second.EndIndex()); |
| 43 | +// const int32_t start_index = (std::min)(first.StartIndex(), second.StartIndex()); |
| 44 | +// const int32_t end_index = (std::max)(first.EndIndex(), second.EndIndex()); |
51 | 45 | // return GetScaleReduction(start_index, end_index, max_buckets);
|
52 | 46 | // }
|
53 | 47 |
|
@@ -91,8 +85,8 @@ Base2ExponentialHistogramAggregation::Base2ExponentialHistogramAggregation(
|
91 | 85 | point_data_.max_buckets_ = ac->max_buckets_;
|
92 | 86 | point_data_.scale_ = ac->max_scale_;
|
93 | 87 | point_data_.record_min_max_ = ac->record_min_max_;
|
94 |
| - point_data_.min_ = std::numeric_limits<double>::max(); |
95 |
| - point_data_.max_ = std::numeric_limits<double>::min(); |
| 88 | + point_data_.min_ = (std::numeric_limits<double>::max)(); |
| 89 | + point_data_.max_ = (std::numeric_limits<double>::min)(); |
96 | 90 |
|
97 | 91 | indexer_ = Base2ExponentialHistogramIndexer(point_data_.scale_);
|
98 | 92 | }
|
@@ -128,8 +122,8 @@ void Base2ExponentialHistogramAggregation::Aggregate(
|
128 | 122 |
|
129 | 123 | if (record_min_max_)
|
130 | 124 | {
|
131 |
| - point_data_.min_ = std::min(point_data_.min_, value); |
132 |
| - point_data_.max_ = std::max(point_data_.max_, value); |
| 125 | + point_data_.min_ = (std::min)(point_data_.min_, value); |
| 126 | + point_data_.max_ = (std::max)(point_data_.max_, value); |
133 | 127 | }
|
134 | 128 |
|
135 | 129 | if (value == 0)
|
@@ -159,8 +153,8 @@ void Base2ExponentialHistogramAggregation::AggregateIntoBuckets(
|
159 | 153 | const int32_t index = indexer_.ComputeIndex(value);
|
160 | 154 | if (!buckets->Increment(index, 1))
|
161 | 155 | {
|
162 |
| - const int32_t start_index = std::min(buckets->StartIndex(), index); |
163 |
| - const int32_t end_index = std::max(buckets->EndIndex(), index); |
| 156 | + const int32_t start_index = (std::min)(buckets->StartIndex(), index); |
| 157 | + const int32_t end_index = (std::max)(buckets->EndIndex(), index); |
164 | 158 | const uint32_t scale_reduction =
|
165 | 159 | GetScaleReduction(start_index, end_index, point_data_.max_buckets_);
|
166 | 160 | Downscale(scale_reduction);
|
@@ -205,13 +199,13 @@ std::unique_ptr<Aggregation> Base2ExponentialHistogramAggregation::Merge(
|
205 | 199 | result_value.count_ = low_res.count_ + high_res.count_;
|
206 | 200 | result_value.sum_ = low_res.sum_ + high_res.sum_;
|
207 | 201 | result_value.zero_count_ = low_res.zero_count_ + high_res.zero_count_;
|
208 |
| - result_value.scale_ = std::min(low_res.scale_, high_res.scale_); |
| 202 | + result_value.scale_ = (std::min)(low_res.scale_, high_res.scale_); |
209 | 203 | result_value.max_buckets_ = low_res.max_buckets_;
|
210 | 204 | result_value.record_min_max_ = low_res.record_min_max_ && high_res.record_min_max_;
|
211 | 205 | if (result_value.record_min_max_)
|
212 | 206 | {
|
213 |
| - result_value.min_ = std::min(low_res.min_, high_res.min_); |
214 |
| - result_value.max_ = std::max(low_res.max_, high_res.max_); |
| 207 | + result_value.min_ = (std::min)(low_res.min_, high_res.min_); |
| 208 | + result_value.max_ = (std::max)(low_res.max_, high_res.max_); |
215 | 209 | }
|
216 | 210 | if (!high_res.positive_buckets_.Empty())
|
217 | 211 | {
|
|
0 commit comments