Skip to content

Commit

Permalink
Simplify SDK Configuration: Use View with default aggregation if no m…
Browse files Browse the repository at this point in the history
…atching View is configured (open-telemetry#1358)
  • Loading branch information
lalitb authored Apr 30, 2022
1 parent 3a4a3a3 commit f314522
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion sdk/include/opentelemetry/sdk/metrics/view/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class View
public:
View(const std::string &name,
const std::string &description = "",
AggregationType aggregation_type = AggregationType::kDrop,
AggregationType aggregation_type = AggregationType::kDefault,
std::unique_ptr<opentelemetry::sdk::metrics::AttributesProcessor> attributes_processor =
std::unique_ptr<opentelemetry::sdk::metrics::AttributesProcessor>(
new opentelemetry::sdk::metrics::DefaultAttributesProcessor()))
Expand Down
2 changes: 1 addition & 1 deletion sdk/include/opentelemetry/sdk/metrics/view/view_registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ViewRegistry
// return default view if none found;
if (!found)
{
static View view("");
static View view("otel-default-view");
if (!callback(view))
{
return false;
Expand Down
16 changes: 9 additions & 7 deletions sdk/test/metrics/view_registry_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ TEST(ViewRegistry, FindViewsEmptyRegistry)
InstrumentationLibrary::Create("default", "1.0.0", "https://opentelemetry.io/schemas/1.7.0");
int count = 0;
ViewRegistry registry;
auto status = registry.FindViews(default_instrument_descriptor,
*default_instrumentation_lib.get(), [&count](const View &view) {
count++;
EXPECT_EQ(view.GetName(), "");
EXPECT_EQ(view.GetDescription(), "");
return true;
});
auto status =
registry.FindViews(default_instrument_descriptor, *default_instrumentation_lib.get(),
[&count](const View &view) {
count++;
EXPECT_EQ(view.GetName(), "otel-default-view");
EXPECT_EQ(view.GetDescription(), "");
EXPECT_EQ(view.GetAggregationType(), AggregationType::kDefault);
return true;
});
EXPECT_EQ(count, 1);
EXPECT_EQ(status, true);
}
Expand Down

0 comments on commit f314522

Please sign in to comment.