-
Notifications
You must be signed in to change notification settings - Fork 511
[METRICS] Add tag to AggregationConfig for aggregation type validation #3732
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
Changes from 4 commits
a2c48c6
d2330d1
177d85a
db221d8
7ec33ec
4d9331c
5dfc194
2c4266b
6f04f06
363eb46
b500f61
af73f3a
f28235c
6179d6f
d3b4c42
8e2a1b0
9dd5eae
36ef49a
5e96531
f30cea6
f150c4a
4b27470
4400651
a530053
01889b2
3867d1d
c1c5d0a
83f6394
b61e528
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 |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| #pragma once | ||
|
|
||
| #include <memory> | ||
| #include <stdexcept> | ||
| #include <string> | ||
|
|
||
| #include "opentelemetry/sdk/metrics/aggregation/aggregation_config.h" | ||
|
|
@@ -36,7 +37,35 @@ class View | |
| aggregation_type_{aggregation_type}, | ||
| aggregation_config_{aggregation_config}, | ||
| attributes_processor_{std::move(attributes_processor)} | ||
| {} | ||
| { | ||
| // Validate that aggregation_type and aggregation_config match | ||
|
||
| if (aggregation_config_) | ||
| { | ||
| AggregationType config_type = aggregation_config_->GetType(); | ||
| bool valid = false; | ||
|
|
||
| switch (aggregation_type_) | ||
| { | ||
| case AggregationType::kHistogram: | ||
| valid = (config_type == AggregationType::kHistogram); | ||
| break; | ||
| case AggregationType::kBase2ExponentialHistogram: | ||
| valid = (config_type == AggregationType::kBase2ExponentialHistogram); | ||
| break; | ||
| case AggregationType::kDefault: | ||
| case AggregationType::kDrop: | ||
| case AggregationType::kLastValue: | ||
| case AggregationType::kSum: | ||
| valid = (config_type == AggregationType::kDefault); | ||
| break; | ||
| } | ||
|
|
||
| if (!valid) | ||
| { | ||
| throw std::invalid_argument("AggregationType and AggregationConfig type mismatch"); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| virtual ~View() = default; | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.