Skip to content

Commit 6468765

Browse files
committed
format
1 parent ea50726 commit 6468765

File tree

5 files changed

+60
-52
lines changed

5 files changed

+60
-52
lines changed

exporters/ostream/src/metric_exporter.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ void OStreamMetricExporter::printPointData(const opentelemetry::sdk::metrics::Po
253253
auto histogram_point_data =
254254
nostd::get<sdk::metrics::Base2ExponentialHistogramPointData>(point_data);
255255
if (!histogram_point_data.positive_buckets_ && !histogram_point_data.negative_buckets_)
256-
{
256+
{
257257
return;
258258
}
259259
sout_ << "\n type: Base2ExponentialHistogramPointData";

exporters/ostream/test/ostream_metric_test.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ TEST(OStreamMetricsExporter, ExportBase2ExponentialHistogramPointData)
194194
histogram_point_data1.record_min_max_ = true;
195195
histogram_point_data1.zero_count_ = 1;
196196
histogram_point_data1.positive_buckets_ =
197-
std::make_unique<opentelemetry::sdk::metrics::AdaptingCircularBufferCounter>(10);
197+
std::make_unique<opentelemetry::sdk::metrics::AdaptingCircularBufferCounter>(10);
198198
histogram_point_data1.negative_buckets_ =
199-
std::make_unique<opentelemetry::sdk::metrics::AdaptingCircularBufferCounter>(10);
199+
std::make_unique<opentelemetry::sdk::metrics::AdaptingCircularBufferCounter>(10);
200200
histogram_point_data1.positive_buckets_->Increment(1, 1);
201201
histogram_point_data1.negative_buckets_->Increment(-2, 1);
202202

@@ -209,9 +209,9 @@ TEST(OStreamMetricsExporter, ExportBase2ExponentialHistogramPointData)
209209
histogram_point_data2.record_min_max_ = false;
210210
histogram_point_data2.zero_count_ = 2;
211211
histogram_point_data2.positive_buckets_ =
212-
std::make_unique<opentelemetry::sdk::metrics::AdaptingCircularBufferCounter>(10);
212+
std::make_unique<opentelemetry::sdk::metrics::AdaptingCircularBufferCounter>(10);
213213
histogram_point_data2.negative_buckets_ =
214-
std::make_unique<opentelemetry::sdk::metrics::AdaptingCircularBufferCounter>(10);
214+
std::make_unique<opentelemetry::sdk::metrics::AdaptingCircularBufferCounter>(10);
215215
histogram_point_data2.positive_buckets_->Increment(3, 1);
216216
histogram_point_data2.negative_buckets_->Increment(-2, 1);
217217
histogram_point_data2.negative_buckets_->Increment(-4, 2);

exporters/otlp/src/otlp_metric_utils.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ void OtlpMetricUtils::ConvertExponentialHistogramMetric(
199199
proto_histogram_point_data->set_time_unix_nano(ts);
200200
auto histogram_data = nostd::get<sdk::metrics::Base2ExponentialHistogramPointData>(
201201
point_data_with_attributes.point_data);
202-
if (histogram_data.positive_buckets_ == nullptr &&
203-
histogram_data.negative_buckets_ == nullptr)
202+
if (histogram_data.positive_buckets_ == nullptr && histogram_data.negative_buckets_ == nullptr)
204203
{
205204
continue;
206205
}

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

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ class Base2ExponentialHistogramPointData
7070
{
7171
public:
7272
Base2ExponentialHistogramPointData(Base2ExponentialHistogramPointData &&) noexcept = default;
73-
Base2ExponentialHistogramPointData &operator=(Base2ExponentialHistogramPointData &&) noexcept = default;
73+
Base2ExponentialHistogramPointData &operator=(Base2ExponentialHistogramPointData &&) noexcept =
74+
default;
7475

7576
Base2ExponentialHistogramPointData(const Base2ExponentialHistogramPointData &other)
7677
: sum_(other.sum_),
@@ -97,19 +98,20 @@ class Base2ExponentialHistogramPointData
9798
{
9899
if (this != &other)
99100
{
100-
sum_ = other.sum_;
101-
min_ = other.min_;
102-
max_ = other.max_;
101+
sum_ = other.sum_;
102+
min_ = other.min_;
103+
max_ = other.max_;
103104
zero_threshold_ = other.zero_threshold_;
104-
count_ = other.count_;
105-
zero_count_ = other.zero_count_;
106-
max_buckets_ = other.max_buckets_;
107-
scale_ = other.scale_;
105+
count_ = other.count_;
106+
zero_count_ = other.zero_count_;
107+
max_buckets_ = other.max_buckets_;
108+
scale_ = other.scale_;
108109
record_min_max_ = other.record_min_max_;
109110

110111
if (other.positive_buckets_)
111112
{
112-
positive_buckets_ = std::make_unique<AdaptingCircularBufferCounter>(*other.positive_buckets_);
113+
positive_buckets_ =
114+
std::make_unique<AdaptingCircularBufferCounter>(*other.positive_buckets_);
113115
}
114116
else
115117
{
@@ -118,7 +120,8 @@ class Base2ExponentialHistogramPointData
118120

119121
if (other.negative_buckets_)
120122
{
121-
negative_buckets_ = std::make_unique<AdaptingCircularBufferCounter>(*other.negative_buckets_);
123+
negative_buckets_ =
124+
std::make_unique<AdaptingCircularBufferCounter>(*other.negative_buckets_);
122125
}
123126
else
124127
{
@@ -132,16 +135,18 @@ class Base2ExponentialHistogramPointData
132135
Base2ExponentialHistogramPointData() = default;
133136

134137
// Members
135-
double sum_ = {};
136-
double min_ = {};
137-
double max_ = {};
138+
double sum_ = {};
139+
double min_ = {};
140+
double max_ = {};
138141
double zero_threshold_ = {};
139-
uint64_t count_ = {};
140-
uint64_t zero_count_ = {};
141-
std::unique_ptr<AdaptingCircularBufferCounter> positive_buckets_ = std::make_unique<AdaptingCircularBufferCounter>(0);
142-
std::unique_ptr<AdaptingCircularBufferCounter> negative_buckets_ = std::make_unique<AdaptingCircularBufferCounter>(0);
143-
size_t max_buckets_ = {};
144-
int32_t scale_ = {};
142+
uint64_t count_ = {};
143+
uint64_t zero_count_ = {};
144+
std::unique_ptr<AdaptingCircularBufferCounter> positive_buckets_ =
145+
std::make_unique<AdaptingCircularBufferCounter>(0);
146+
std::unique_ptr<AdaptingCircularBufferCounter> negative_buckets_ =
147+
std::make_unique<AdaptingCircularBufferCounter>(0);
148+
size_t max_buckets_ = {};
149+
int32_t scale_ = {};
145150
bool record_min_max_ = true;
146151
};
147152

sdk/src/metrics/aggregation/base2_exponential_histogram_aggregation.cc

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
#include <stddef.h>
55
#include <stdint.h>
66
#include <algorithm>
7+
#include <iostream>
78
#include <limits>
89
#include <memory>
910
#include <mutex>
1011
#include <utility>
11-
#include <iostream>
1212

1313
#include "opentelemetry/common/spin_lock_mutex.h"
1414
#include "opentelemetry/nostd/variant.h"
@@ -86,36 +86,38 @@ Base2ExponentialHistogramAggregation::Base2ExponentialHistogramAggregation(
8686
point_data_.max_ = (std::numeric_limits<double>::min)();
8787

8888
// Initialize buckets
89-
point_data_.positive_buckets_ = std::make_unique<AdaptingCircularBufferCounter>(point_data_.max_buckets_);
90-
point_data_.negative_buckets_ = std::make_unique<AdaptingCircularBufferCounter>(point_data_.max_buckets_);
89+
point_data_.positive_buckets_ =
90+
std::make_unique<AdaptingCircularBufferCounter>(point_data_.max_buckets_);
91+
point_data_.negative_buckets_ =
92+
std::make_unique<AdaptingCircularBufferCounter>(point_data_.max_buckets_);
9193

9294
indexer_ = Base2ExponentialHistogramIndexer(point_data_.scale_);
9395
}
9496

9597
Base2ExponentialHistogramAggregation::Base2ExponentialHistogramAggregation(
9698
const Base2ExponentialHistogramPointData &point_data)
97-
: point_data_{},
98-
indexer_(point_data.scale_),
99-
record_min_max_{point_data.record_min_max_}
99+
: point_data_{}, indexer_(point_data.scale_), record_min_max_{point_data.record_min_max_}
100100
{
101-
point_data_.sum_ = point_data.sum_;
102-
point_data_.min_ = point_data.min_;
103-
point_data_.max_ = point_data.max_;
101+
point_data_.sum_ = point_data.sum_;
102+
point_data_.min_ = point_data.min_;
103+
point_data_.max_ = point_data.max_;
104104
point_data_.zero_threshold_ = point_data.zero_threshold_;
105-
point_data_.count_ = point_data.count_;
106-
point_data_.zero_count_ = point_data.zero_count_;
107-
point_data_.max_buckets_ = point_data.max_buckets_;
108-
point_data_.scale_ = point_data.scale_;
105+
point_data_.count_ = point_data.count_;
106+
point_data_.zero_count_ = point_data.zero_count_;
107+
point_data_.max_buckets_ = point_data.max_buckets_;
108+
point_data_.scale_ = point_data.scale_;
109109
point_data_.record_min_max_ = point_data.record_min_max_;
110110

111111
// Deep copy the unique_ptr members
112112
if (point_data.positive_buckets_)
113113
{
114-
point_data_.positive_buckets_ = std::make_unique<AdaptingCircularBufferCounter>(*point_data.positive_buckets_);
114+
point_data_.positive_buckets_ =
115+
std::make_unique<AdaptingCircularBufferCounter>(*point_data.positive_buckets_);
115116
}
116117
if (point_data.negative_buckets_)
117118
{
118-
point_data_.negative_buckets_ = std::make_unique<AdaptingCircularBufferCounter>(*point_data.negative_buckets_);
119+
point_data_.negative_buckets_ =
120+
std::make_unique<AdaptingCircularBufferCounter>(*point_data.negative_buckets_);
119121
}
120122
}
121123

@@ -401,8 +403,8 @@ std::unique_ptr<Aggregation> Base2ExponentialHistogramAggregation::Diff(
401403
result_value.scale_ = low_res.scale_;
402404
result_value.max_buckets_ = low_res.max_buckets_;
403405
result_value.record_min_max_ = false;
404-
result_value.count_ = (right.count_ >= left.count_) ? (right.count_ - left.count_) : 0;
405-
result_value.sum_ = (right.sum_ >= left.sum_) ? (right.sum_ - left.sum_) : 0.0;
406+
result_value.count_ = (right.count_ >= left.count_) ? (right.count_ - left.count_) : 0;
407+
result_value.sum_ = (right.sum_ >= left.sum_) ? (right.sum_ - left.sum_) : 0.0;
406408
result_value.zero_count_ =
407409
(right.zero_count_ >= left.zero_count_) ? (right.zero_count_ - left.zero_count_) : 0;
408410

@@ -448,23 +450,25 @@ PointType Base2ExponentialHistogramAggregation::ToPoint() const noexcept
448450
const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_);
449451

450452
Base2ExponentialHistogramPointData copy;
451-
copy.sum_ = point_data_.sum_;
452-
copy.min_ = point_data_.min_;
453-
copy.max_ = point_data_.max_;
453+
copy.sum_ = point_data_.sum_;
454+
copy.min_ = point_data_.min_;
455+
copy.max_ = point_data_.max_;
454456
copy.zero_threshold_ = point_data_.zero_threshold_;
455-
copy.count_ = point_data_.count_;
456-
copy.zero_count_ = point_data_.zero_count_;
457-
copy.max_buckets_ = point_data_.max_buckets_;
458-
copy.scale_ = point_data_.scale_;
457+
copy.count_ = point_data_.count_;
458+
copy.zero_count_ = point_data_.zero_count_;
459+
copy.max_buckets_ = point_data_.max_buckets_;
460+
copy.scale_ = point_data_.scale_;
459461
copy.record_min_max_ = point_data_.record_min_max_;
460462

461463
if (point_data_.positive_buckets_)
462464
{
463-
copy.positive_buckets_ = std::make_unique<AdaptingCircularBufferCounter>(*point_data_.positive_buckets_);
465+
copy.positive_buckets_ =
466+
std::make_unique<AdaptingCircularBufferCounter>(*point_data_.positive_buckets_);
464467
}
465468
if (point_data_.negative_buckets_)
466469
{
467-
copy.negative_buckets_ = std::make_unique<AdaptingCircularBufferCounter>(*point_data_.negative_buckets_);
470+
copy.negative_buckets_ =
471+
std::make_unique<AdaptingCircularBufferCounter>(*point_data_.negative_buckets_);
468472
}
469473

470474
return copy;

0 commit comments

Comments
 (0)