Skip to content

Commit 9146925

Browse files
committed
Fix windows build errors
1 parent 43c0e00 commit 9146925

File tree

3 files changed

+18
-26
lines changed

3 files changed

+18
-26
lines changed

sdk/include/opentelemetry/sdk/metrics/data/circular_buffer.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
#pragma once
55

6-
#include <stddef.h>
7-
#include <cstdint>
86
#include <limits>
97
#include <vector>
108

@@ -144,7 +142,7 @@ class AdaptingCircularBufferCounter
144142
private:
145143
size_t ToBufferIndex(int32_t index) const;
146144

147-
static constexpr int32_t kNullIndex = std::numeric_limits<int32_t>::min();
145+
static constexpr int32_t kNullIndex = (std::numeric_limits<int32_t>::min)();
148146

149147
// Index of the first populated element, may be kNullIndex if container is empty.
150148
int32_t start_index_ = kNullIndex;

sdk/src/metrics/aggregation/base2_exponential_histogram_aggregation.cc

+15-21
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
// Copyright The OpenTelemetry Authors
22
// SPDX-License-Identifier: Apache-2.0
33

4+
#include <cmath>
5+
#include <iostream>
6+
#include <limits>
7+
48
#include "opentelemetry/sdk/metrics/aggregation/base2_exponential_histogram_aggregation.h"
5-
#include "opentelemetry/sdk/metrics/aggregation/aggregation.h"
69
#include "opentelemetry/sdk/metrics/data/circular_buffer.h"
710
#include "opentelemetry/sdk/metrics/data/point_data.h"
811
#include "opentelemetry/version.h"
912

10-
#include <cmath>
11-
#include <cstddef>
12-
#include <exception>
13-
#include <limits>
14-
#include <memory>
15-
#include <mutex>
16-
17-
#include <iostream>
18-
1913
OPENTELEMETRY_BEGIN_NAMESPACE
2014
namespace sdk
2115
{
@@ -46,8 +40,8 @@ uint32_t GetScaleReduction(int32_t start_index, int32_t end_index, size_t max_bu
4640
// {
4741
// return 0;
4842
// }
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());
5145
// return GetScaleReduction(start_index, end_index, max_buckets);
5246
// }
5347

@@ -91,8 +85,8 @@ Base2ExponentialHistogramAggregation::Base2ExponentialHistogramAggregation(
9185
point_data_.max_buckets_ = ac->max_buckets_;
9286
point_data_.scale_ = ac->max_scale_;
9387
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)();
9690

9791
indexer_ = Base2ExponentialHistogramIndexer(point_data_.scale_);
9892
}
@@ -128,8 +122,8 @@ void Base2ExponentialHistogramAggregation::Aggregate(
128122

129123
if (record_min_max_)
130124
{
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);
133127
}
134128

135129
if (value == 0)
@@ -159,8 +153,8 @@ void Base2ExponentialHistogramAggregation::AggregateIntoBuckets(
159153
const int32_t index = indexer_.ComputeIndex(value);
160154
if (!buckets->Increment(index, 1))
161155
{
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);
164158
const uint32_t scale_reduction =
165159
GetScaleReduction(start_index, end_index, point_data_.max_buckets_);
166160
Downscale(scale_reduction);
@@ -205,13 +199,13 @@ std::unique_ptr<Aggregation> Base2ExponentialHistogramAggregation::Merge(
205199
result_value.count_ = low_res.count_ + high_res.count_;
206200
result_value.sum_ = low_res.sum_ + high_res.sum_;
207201
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_);
209203
result_value.max_buckets_ = low_res.max_buckets_;
210204
result_value.record_min_max_ = low_res.record_min_max_ && high_res.record_min_max_;
211205
if (result_value.record_min_max_)
212206
{
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_);
215209
}
216210
if (!high_res.positive_buckets_.Empty())
217211
{

sdk/test/metrics/aggregation_test.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ TEST(aggregation, Base2ExponentialHistogramAggregation)
241241
EXPECT_EQ(histo_point.count_, 0);
242242
EXPECT_EQ(histo_point.sum_, 0.0);
243243
EXPECT_EQ(histo_point.zero_count_, 0);
244-
EXPECT_EQ(histo_point.min_, std::numeric_limits<double>::max());
245-
EXPECT_EQ(histo_point.max_, std::numeric_limits<double>::min());
244+
EXPECT_EQ(histo_point.min_, (std::numeric_limits<double>::max)());
245+
EXPECT_EQ(histo_point.max_, (std::numeric_limits<double>::min)());
246246
EXPECT_EQ(histo_point.scale_, SCALE0);
247247
EXPECT_EQ(histo_point.max_buckets_, MAX_BUCKETS0);
248248
ASSERT_TRUE(histo_point.positive_buckets_.Empty());

0 commit comments

Comments
 (0)