-
Notifications
You must be signed in to change notification settings - Fork 417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Metrics SDK] Histogram min/max support #1540
Changes from all commits
0bec005
8837a96
fe9dc5d
678e9f9
dff9422
6b6bb43
1952c67
d1b4585
6753e6f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ class HistogramAggregationConfig : public AggregationConfig | |
{ | ||
public: | ||
std::list<T> boundaries_; | ||
bool record_min_max_ = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Pls ignore, it's been used. Sorry about that. |
||
}; | ||
} // namespace metrics | ||
} // namespace sdk | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ class LongHistogramAggregation : public Aggregation | |
private: | ||
opentelemetry::common::SpinLockMutex lock_; | ||
HistogramPointData point_data_; | ||
bool record_min_max_ = true; | ||
}; | ||
|
||
class DoubleHistogramAggregation : public Aggregation | ||
|
@@ -72,6 +73,7 @@ class DoubleHistogramAggregation : public Aggregation | |
private: | ||
mutable opentelemetry::common::SpinLockMutex lock_; | ||
mutable HistogramPointData point_data_; | ||
bool record_min_max_ = true; | ||
}; | ||
|
||
template <class T> | ||
|
@@ -83,9 +85,15 @@ void HistogramMerge(HistogramPointData ¤t, | |
{ | ||
merge.counts_[i] = current.counts_[i] + delta.counts_[i]; | ||
} | ||
merge.boundaries_ = current.boundaries_; | ||
merge.sum_ = nostd::get<T>(current.sum_) + nostd::get<T>(delta.sum_); | ||
merge.count_ = current.count_ + delta.count_; | ||
merge.boundaries_ = current.boundaries_; | ||
merge.sum_ = nostd::get<T>(current.sum_) + nostd::get<T>(delta.sum_); | ||
merge.count_ = current.count_ + delta.count_; | ||
merge.record_min_max_ = current.record_min_max_ && delta.record_min_max_; | ||
if (merge.record_min_max_) | ||
{ | ||
merge.min_ = std::min(nostd::get<T>(current.min_), nostd::get<T>(delta.min_)); | ||
merge.max_ = std::max(nostd::get<T>(current.max_), nostd::get<T>(delta.max_)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure how to handle for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I set it to |
||
} | ||
} | ||
|
||
template <class T> | ||
|
@@ -95,8 +103,9 @@ void HistogramDiff(HistogramPointData ¤t, HistogramPointData &next, Histog | |
{ | ||
diff.counts_[i] = next.counts_[i] - current.counts_[i]; | ||
} | ||
diff.boundaries_ = current.boundaries_; | ||
diff.count_ = next.count_ - current.count_; | ||
diff.boundaries_ = current.boundaries_; | ||
diff.count_ = next.count_ - current.count_; | ||
diff.record_min_max_ = false; | ||
} | ||
|
||
} // namespace metrics | ||
|
+12 −1 | CHANGELOG.md | |
+1 −1 | README.md | |
+1 −1 | opentelemetry/proto/metrics/v1/metrics.proto |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these values 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was because
histogram_point_data
, had default min and max.thanks, added proper min & max now.