diff --git a/sdk/include/opentelemetry/sdk/metrics/view/view_registry.h b/sdk/include/opentelemetry/sdk/metrics/view/view_registry.h index 4f1cdad2fe..41755d23bf 100644 --- a/sdk/include/opentelemetry/sdk/metrics/view/view_registry.h +++ b/sdk/include/opentelemetry/sdk/metrics/view/view_registry.h @@ -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; diff --git a/sdk/test/metrics/view_registry_test.cc b/sdk/test/metrics/view_registry_test.cc index 7f6c6d23fe..a6b0115f42 100644 --- a/sdk/test/metrics/view_registry_test.cc +++ b/sdk/test/metrics/view_registry_test.cc @@ -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) @@ -76,7 +80,9 @@ TEST(ViewRegistry, FindNonExistingView) # endif return true; }); +# if HAVE_WORKING_REGEX EXPECT_EQ(count, 1); EXPECT_EQ(status, true); +# endif } #endif