From b5f2bcd91447343e31d4457ba1cd16204e16ddd9 Mon Sep 17 00:00:00 2001 From: Ehsan Saei <71217171+esigo@users.noreply.github.com> Date: Wed, 10 Aug 2022 18:41:39 +0200 Subject: [PATCH] Fix default Metric view name (#1515) --- .../opentelemetry/sdk/metrics/view/view_registry.h | 2 +- sdk/test/metrics/view_registry_test.cc | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) 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