|
4 | 4 | #include <stddef.h> |
5 | 5 | #include <stdint.h> |
6 | 6 | #include <algorithm> |
| 7 | +#include <iostream> |
7 | 8 | #include <limits> |
8 | 9 | #include <memory> |
9 | 10 | #include <mutex> |
10 | 11 | #include <utility> |
11 | | -#include <iostream> |
12 | 12 |
|
13 | 13 | #include "opentelemetry/common/spin_lock_mutex.h" |
14 | 14 | #include "opentelemetry/nostd/variant.h" |
@@ -86,36 +86,38 @@ Base2ExponentialHistogramAggregation::Base2ExponentialHistogramAggregation( |
86 | 86 | point_data_.max_ = (std::numeric_limits<double>::min)(); |
87 | 87 |
|
88 | 88 | // 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_); |
91 | 93 |
|
92 | 94 | indexer_ = Base2ExponentialHistogramIndexer(point_data_.scale_); |
93 | 95 | } |
94 | 96 |
|
95 | 97 | Base2ExponentialHistogramAggregation::Base2ExponentialHistogramAggregation( |
96 | 98 | 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_} |
100 | 100 | { |
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_; |
104 | 104 | 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_; |
109 | 109 | point_data_.record_min_max_ = point_data.record_min_max_; |
110 | 110 |
|
111 | 111 | // Deep copy the unique_ptr members |
112 | 112 | if (point_data.positive_buckets_) |
113 | 113 | { |
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_); |
115 | 116 | } |
116 | 117 | if (point_data.negative_buckets_) |
117 | 118 | { |
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_); |
119 | 121 | } |
120 | 122 | } |
121 | 123 |
|
@@ -401,8 +403,8 @@ std::unique_ptr<Aggregation> Base2ExponentialHistogramAggregation::Diff( |
401 | 403 | result_value.scale_ = low_res.scale_; |
402 | 404 | result_value.max_buckets_ = low_res.max_buckets_; |
403 | 405 | 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; |
406 | 408 | result_value.zero_count_ = |
407 | 409 | (right.zero_count_ >= left.zero_count_) ? (right.zero_count_ - left.zero_count_) : 0; |
408 | 410 |
|
@@ -448,23 +450,25 @@ PointType Base2ExponentialHistogramAggregation::ToPoint() const noexcept |
448 | 450 | const std::lock_guard<opentelemetry::common::SpinLockMutex> locked(lock_); |
449 | 451 |
|
450 | 452 | 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_; |
454 | 456 | 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_; |
459 | 461 | copy.record_min_max_ = point_data_.record_min_max_; |
460 | 462 |
|
461 | 463 | if (point_data_.positive_buckets_) |
462 | 464 | { |
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_); |
464 | 467 | } |
465 | 468 | if (point_data_.negative_buckets_) |
466 | 469 | { |
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_); |
468 | 472 | } |
469 | 473 |
|
470 | 474 | return copy; |
|
0 commit comments