Skip to content

Commit

Permalink
Fix default Metric view name (open-telemetry#1515)
Browse files Browse the repository at this point in the history
  • Loading branch information
esigo authored and yxue committed Dec 5, 2022
1 parent a078987 commit b5f2bcd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
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("otel-default-view");
static const View view("");
if (!callback(view))
{
return false;
Expand Down
8 changes: 7 additions & 1 deletion sdk/test/metrics/view_registry_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@ TEST(ViewRegistry, FindViewsEmptyRegistry)
registry.FindViews(default_instrument_descriptor, *default_instrumentation_scope.get(),
[&count](const View &view) {
count++;
EXPECT_EQ(view.GetName(), "otel-default-view");
# if HAVE_WORKING_REGEX
EXPECT_EQ(view.GetName(), "");
EXPECT_EQ(view.GetDescription(), "");
# endif
EXPECT_EQ(view.GetAggregationType(), AggregationType::kDefault);
return true;
});
# if HAVE_WORKING_REGEX
EXPECT_EQ(count, 1);
EXPECT_EQ(status, true);
# endif
}

TEST(ViewRegistry, FindNonExistingView)
Expand Down Expand Up @@ -76,7 +80,9 @@ TEST(ViewRegistry, FindNonExistingView)
# endif
return true;
});
# if HAVE_WORKING_REGEX
EXPECT_EQ(count, 1);
EXPECT_EQ(status, true);
# endif
}
#endif

0 comments on commit b5f2bcd

Please sign in to comment.