[metrics] Change the example chrome metric to not clash with chromium

Since we have not implemented a good way to shadow proto and sql files
between what's loaded in memory (proto and sql files checked into
perfetto) and what's loaded at runtime (proto and sql files checked into
chromium/src/.../tbmv3), having duplicate metrics can lead to a lot
of trouble. In particular, it will stop working if we enforce single
definition of messages as in https://r.android.com/1386237. The
libprotobuf descriptor pool in trace_processor_shell already rejects
the runtime-loaded definition of console_error_metric, so this can
lead to many subtle bugs.

We will have a proper virtual file system with well defined shadowing
soon, and then this test chrome metric will go away to be replaced with
all metrics rolled in from chromium.

Bug: 161697620
Change-Id: Iede9af8a04d4e352c0323b36e698ee6805de2cab
diff --git a/Android.bp b/Android.bp
index a682da4..1da2804 100644
--- a/Android.bp
+++ b/Android.bp
@@ -56,7 +56,6 @@
     "src/trace_processor/metrics/android/unmapped_java_symbols.sql",
     "src/trace_processor/metrics/android/unsymbolized_frames.sql",
     "src/trace_processor/metrics/chrome/chrome_processes.sql",
-    "src/trace_processor/metrics/chrome/console_error_metric.sql",
     "src/trace_processor/metrics/chrome/scroll_flow_event.sql",
     "src/trace_processor/metrics/chrome/scroll_flow_event_queuing_delay.sql",
     "src/trace_processor/metrics/chrome/scroll_jank.sql",
@@ -64,6 +63,7 @@
     "src/trace_processor/metrics/chrome/scroll_jank_cause_blocking_task.sql",
     "src/trace_processor/metrics/chrome/scroll_jank_cause_blocking_touch_move.sql",
     "src/trace_processor/metrics/chrome/scroll_jank_cause_queuing_delay.sql",
+    "src/trace_processor/metrics/chrome/test_chrome_metric.sql",
     "src/trace_processor/metrics/trace_metadata.sql",
     "src/trace_processor/metrics/webview/webview_power_usage.sql",
   ],
diff --git a/BUILD b/BUILD
index d4b4045..2017850 100644
--- a/BUILD
+++ b/BUILD
@@ -783,7 +783,6 @@
         "src/trace_processor/metrics/android/unmapped_java_symbols.sql",
         "src/trace_processor/metrics/android/unsymbolized_frames.sql",
         "src/trace_processor/metrics/chrome/chrome_processes.sql",
-        "src/trace_processor/metrics/chrome/console_error_metric.sql",
         "src/trace_processor/metrics/chrome/scroll_flow_event.sql",
         "src/trace_processor/metrics/chrome/scroll_flow_event_queuing_delay.sql",
         "src/trace_processor/metrics/chrome/scroll_jank.sql",
@@ -791,6 +790,7 @@
         "src/trace_processor/metrics/chrome/scroll_jank_cause_blocking_task.sql",
         "src/trace_processor/metrics/chrome/scroll_jank_cause_blocking_touch_move.sql",
         "src/trace_processor/metrics/chrome/scroll_jank_cause_queuing_delay.sql",
+        "src/trace_processor/metrics/chrome/test_chrome_metric.sql",
         "src/trace_processor/metrics/trace_metadata.sql",
         "src/trace_processor/metrics/webview/webview_power_usage.sql",
     ],
diff --git a/protos/perfetto/metrics/chrome/BUILD.gn b/protos/perfetto/metrics/chrome/BUILD.gn
index 012a2c0..511b1ef 100644
--- a/protos/perfetto/metrics/chrome/BUILD.gn
+++ b/protos/perfetto/metrics/chrome/BUILD.gn
@@ -18,6 +18,6 @@
   deps = [ "../metrics:@TYPE@" ]
   sources = [
     "all_chrome_metrics.proto",
-    "console_error_metric.proto",
+    "test_chrome_metric.proto",
   ]
 }
diff --git a/protos/perfetto/metrics/chrome/all_chrome_metrics.proto b/protos/perfetto/metrics/chrome/all_chrome_metrics.proto
index 1b2a874..6863170 100644
--- a/protos/perfetto/metrics/chrome/all_chrome_metrics.proto
+++ b/protos/perfetto/metrics/chrome/all_chrome_metrics.proto
@@ -19,8 +19,8 @@
 package perfetto.protos;
 
 import "protos/perfetto/metrics/metrics.proto";
-import "protos/perfetto/metrics/chrome/console_error_metric.proto";
+import "protos/perfetto/metrics/chrome/test_chrome_metric.proto";
 
 extend TraceMetrics {
-  optional ConsoleErrorMetric console_error_metric = 1001;
+  optional TestChromeMetric test_chrome_metric = 1001;
 }
diff --git a/protos/perfetto/metrics/chrome/console_error_metric.proto b/protos/perfetto/metrics/chrome/test_chrome_metric.proto
similarity index 75%
rename from protos/perfetto/metrics/chrome/console_error_metric.proto
rename to protos/perfetto/metrics/chrome/test_chrome_metric.proto
index e22189e..3ae3240 100644
--- a/protos/perfetto/metrics/chrome/console_error_metric.proto
+++ b/protos/perfetto/metrics/chrome/test_chrome_metric.proto
@@ -20,8 +20,6 @@
 
 import "protos/perfetto/metrics/custom_options.proto";
 
-message ConsoleErrorMetric {
-  optional int64 all_errors = 1 [(unit) = "count_smallerIsBetter"];
-  optional int64 js_errors = 2 [(unit) = "count_smallerIsBetter"];
-  optional int64 network_errors = 3 [(unit) = "count_smallerIsBetter"];
+message TestChromeMetric {
+  optional int64 test_value = 1 [(unit) = "count_smallerIsBetter"];
 }
diff --git a/src/trace_processor/metrics/BUILD.gn b/src/trace_processor/metrics/BUILD.gn
index 5e285bc..d05e3ce 100644
--- a/src/trace_processor/metrics/BUILD.gn
+++ b/src/trace_processor/metrics/BUILD.gn
@@ -62,7 +62,7 @@
   "chrome/scroll_jank_cause_queuing_delay.sql",
   "chrome/scroll_flow_event.sql",
   "chrome/scroll_flow_event_queuing_delay.sql",
-  "chrome/console_error_metric.sql",
+  "chrome/test_chrome_metric.sql",
   "webview/webview_power_usage.sql",
 ]
 
diff --git a/src/trace_processor/metrics/chrome/all_chrome_metrics.descriptor.h b/src/trace_processor/metrics/chrome/all_chrome_metrics.descriptor.h
index 4a1dfa9..0ed9bd8 100644
--- a/src/trace_processor/metrics/chrome/all_chrome_metrics.descriptor.h
+++ b/src/trace_processor/metrics/chrome/all_chrome_metrics.descriptor.h
@@ -27,14 +27,14 @@
 // SHA1(tools/gen_binary_descriptors)
 // 8415a60487a92e45fc37158f1b86f495ebede0ce
 // SHA1(protos/perfetto/metrics/chrome/all_chrome_metrics.proto)
-// f2a7367c1cc15c70d581f137af270765ebac547a
+// 9a32656dee7a694a48fe439212ca3276a30a8680
 
 // This is the proto AllChromeMetrics encoded as a ProtoFileDescriptor to allow
 // for reflection without libprotobuf full/non-lite protos.
 
 namespace perfetto {
 
-constexpr std::array<uint8_t, 27496> kAllChromeMetricsDescriptor{
+constexpr std::array<uint8_t, 27361> kAllChromeMetricsDescriptor{
     {0x0a, 0xf3, 0x06, 0x0a, 0x31, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f,
      0x70, 0x65, 0x72, 0x66, 0x65, 0x74, 0x74, 0x6f, 0x2f, 0x6d, 0x65, 0x74,
      0x72, 0x69, 0x63, 0x73, 0x2f, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64,
@@ -2274,59 +2274,48 @@
      0x46, 0x69, 0x65, 0x6c, 0x64, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73,
      0x18, 0xd2, 0x86, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, 0x69, 0x6d,
      0x70, 0x72, 0x6f, 0x76, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x69, 0x72,
-     0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0xc5, 0x02, 0x0a, 0x39, 0x70,
+     0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0xc6, 0x01, 0x0a, 0x37, 0x70,
      0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x70, 0x65, 0x72, 0x66, 0x65, 0x74,
      0x74, 0x6f, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2f, 0x63,
-     0x68, 0x72, 0x6f, 0x6d, 0x65, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c,
-     0x65, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x65, 0x74, 0x72,
-     0x69, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x70, 0x65,
-     0x72, 0x66, 0x65, 0x74, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
-     0x73, 0x1a, 0x2c, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x70, 0x65,
-     0x72, 0x66, 0x65, 0x74, 0x74, 0x6f, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69,
-     0x63, 0x73, 0x2f, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x5f, 0x6f, 0x70,
-     0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
-     0xc8, 0x01, 0x0a, 0x12, 0x43, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x45,
-     0x72, 0x72, 0x6f, 0x72, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x12, 0x38,
-     0x0a, 0x0a, 0x61, 0x6c, 0x6c, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73,
-     0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42, 0x19, 0x8a, 0xb5, 0x18, 0x15,
-     0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x73, 0x6d, 0x61, 0x6c, 0x6c, 0x65,
-     0x72, 0x49, 0x73, 0x42, 0x65, 0x74, 0x74, 0x65, 0x72, 0x52, 0x09, 0x61,
-     0x6c, 0x6c, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x12, 0x36, 0x0a, 0x09,
-     0x6a, 0x73, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x18, 0x02, 0x20,
-     0x01, 0x28, 0x03, 0x42, 0x19, 0x8a, 0xb5, 0x18, 0x15, 0x63, 0x6f, 0x75,
-     0x6e, 0x74, 0x5f, 0x73, 0x6d, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x49, 0x73,
-     0x42, 0x65, 0x74, 0x74, 0x65, 0x72, 0x52, 0x08, 0x6a, 0x73, 0x45, 0x72,
-     0x72, 0x6f, 0x72, 0x73, 0x12, 0x40, 0x0a, 0x0e, 0x6e, 0x65, 0x74, 0x77,
-     0x6f, 0x72, 0x6b, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x18, 0x03,
-     0x20, 0x01, 0x28, 0x03, 0x42, 0x19, 0x8a, 0xb5, 0x18, 0x15, 0x63, 0x6f,
-     0x75, 0x6e, 0x74, 0x5f, 0x73, 0x6d, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x49,
-     0x73, 0x42, 0x65, 0x74, 0x74, 0x65, 0x72, 0x52, 0x0d, 0x6e, 0x65, 0x74,
-     0x77, 0x6f, 0x72, 0x6b, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x0a, 0xa3,
-     0x02, 0x0a, 0x37, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x70, 0x65,
-     0x72, 0x66, 0x65, 0x74, 0x74, 0x6f, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69,
-     0x63, 0x73, 0x2f, 0x63, 0x68, 0x72, 0x6f, 0x6d, 0x65, 0x2f, 0x61, 0x6c,
-     0x6c, 0x5f, 0x63, 0x68, 0x72, 0x6f, 0x6d, 0x65, 0x5f, 0x6d, 0x65, 0x74,
-     0x72, 0x69, 0x63, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f,
-     0x70, 0x65, 0x72, 0x66, 0x65, 0x74, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f,
-     0x74, 0x6f, 0x73, 0x1a, 0x25, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f,
-     0x70, 0x65, 0x72, 0x66, 0x65, 0x74, 0x74, 0x6f, 0x2f, 0x6d, 0x65, 0x74,
-     0x72, 0x69, 0x63, 0x73, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73,
-     0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x39, 0x70, 0x72, 0x6f, 0x74,
+     0x68, 0x72, 0x6f, 0x6d, 0x65, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x63,
+     0x68, 0x72, 0x6f, 0x6d, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63,
+     0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x70, 0x65, 0x72, 0x66,
+     0x65, 0x74, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x1a,
+     0x2c, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x70, 0x65, 0x72, 0x66,
+     0x65, 0x74, 0x74, 0x6f, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73,
+     0x2f, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x5f, 0x6f, 0x70, 0x74, 0x69,
+     0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x4c, 0x0a,
+     0x10, 0x54, 0x65, 0x73, 0x74, 0x43, 0x68, 0x72, 0x6f, 0x6d, 0x65, 0x4d,
+     0x65, 0x74, 0x72, 0x69, 0x63, 0x12, 0x38, 0x0a, 0x0a, 0x74, 0x65, 0x73,
+     0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
+     0x03, 0x42, 0x19, 0x8a, 0xb5, 0x18, 0x15, 0x63, 0x6f, 0x75, 0x6e, 0x74,
+     0x5f, 0x73, 0x6d, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x49, 0x73, 0x42, 0x65,
+     0x74, 0x74, 0x65, 0x72, 0x52, 0x09, 0x74, 0x65, 0x73, 0x74, 0x56, 0x61,
+     0x6c, 0x75, 0x65, 0x0a, 0x9b, 0x02, 0x0a, 0x37, 0x70, 0x72, 0x6f, 0x74,
      0x6f, 0x73, 0x2f, 0x70, 0x65, 0x72, 0x66, 0x65, 0x74, 0x74, 0x6f, 0x2f,
      0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2f, 0x63, 0x68, 0x72, 0x6f,
-     0x6d, 0x65, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x5f, 0x65,
-     0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x2e,
-     0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3a, 0x75, 0x0a, 0x14, 0x63, 0x6f, 0x6e,
-     0x73, 0x6f, 0x6c, 0x65, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d,
-     0x65, 0x74, 0x72, 0x69, 0x63, 0x12, 0x1d, 0x2e, 0x70, 0x65, 0x72, 0x66,
-     0x65, 0x74, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2e,
-     0x54, 0x72, 0x61, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73,
-     0x18, 0xe9, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x70, 0x65,
-     0x72, 0x66, 0x65, 0x74, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
-     0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x45, 0x72, 0x72,
-     0x6f, 0x72, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x52, 0x12, 0x63, 0x6f,
-     0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x65,
-     0x74, 0x72, 0x69, 0x63}};
+     0x6d, 0x65, 0x2f, 0x61, 0x6c, 0x6c, 0x5f, 0x63, 0x68, 0x72, 0x6f, 0x6d,
+     0x65, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x70, 0x72,
+     0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x70, 0x65, 0x72, 0x66, 0x65, 0x74, 0x74,
+     0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x1a, 0x25, 0x70, 0x72,
+     0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x70, 0x65, 0x72, 0x66, 0x65, 0x74, 0x74,
+     0x6f, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2f, 0x6d, 0x65,
+     0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a,
+     0x37, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x70, 0x65, 0x72, 0x66,
+     0x65, 0x74, 0x74, 0x6f, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73,
+     0x2f, 0x63, 0x68, 0x72, 0x6f, 0x6d, 0x65, 0x2f, 0x74, 0x65, 0x73, 0x74,
+     0x5f, 0x63, 0x68, 0x72, 0x6f, 0x6d, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x72,
+     0x69, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3a, 0x6f, 0x0a, 0x12,
+     0x74, 0x65, 0x73, 0x74, 0x5f, 0x63, 0x68, 0x72, 0x6f, 0x6d, 0x65, 0x5f,
+     0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x12, 0x1d, 0x2e, 0x70, 0x65, 0x72,
+     0x66, 0x65, 0x74, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73,
+     0x2e, 0x54, 0x72, 0x61, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63,
+     0x73, 0x18, 0xe9, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x70,
+     0x65, 0x72, 0x66, 0x65, 0x74, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74,
+     0x6f, 0x73, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x43, 0x68, 0x72, 0x6f, 0x6d,
+     0x65, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x52, 0x10, 0x74, 0x65, 0x73,
+     0x74, 0x43, 0x68, 0x72, 0x6f, 0x6d, 0x65, 0x4d, 0x65, 0x74, 0x72, 0x69,
+     0x63}};
 
 }  // namespace perfetto
 
diff --git a/src/trace_processor/metrics/chrome/console_error_metric.sql b/src/trace_processor/metrics/chrome/console_error_metric.sql
deleted file mode 100644
index 809ade3..0000000
--- a/src/trace_processor/metrics/chrome/console_error_metric.sql
+++ /dev/null
@@ -1,31 +0,0 @@
--- Copyright 2019 Google LLC.
--- SPDX-License-Identifier: Apache-2.0
-
-CREATE VIEW console_error_events AS
-SELECT args.string_value as source
-from slices
-inner join args using(arg_set_id)
-where slices.name = "ConsoleMessage::Error"
-  and slices.category = "blink.console"
-  and args.flat_key = "debug.source"
-UNION ALL
-SELECT "JS" AS source
-FROM slices
-WHERE slices.category = 'v8.console' AND (
-  slices.name = 'V8ConsoleMessage::Exception' OR
-  slices.name = 'V8ConsoleMessage::Error' OR
-  slices.name = 'V8ConsoleMessage::Assert'
-);
-
-CREATE VIEW console_error_metric AS
-SELECT
-  (SELECT COUNT(*) FROM console_error_events) as all_errors,
-  (SELECT COUNT(*) FROM console_error_events where source = "JS") as js_errors,
-  (SELECT COUNT(*) FROM console_error_events where source = "Network") as network_errors;
-
-CREATE VIEW console_error_metric_output AS
-SELECT ConsoleErrorMetric(
-  'all_errors', all_errors,
-  'js_errors', js_errors,
-  'network_errors', network_errors)
-FROM console_error_metric
diff --git a/src/trace_processor/metrics/chrome/test_chrome_metric.sql b/src/trace_processor/metrics/chrome/test_chrome_metric.sql
new file mode 100644
index 0000000..4cce8e1
--- /dev/null
+++ b/src/trace_processor/metrics/chrome/test_chrome_metric.sql
@@ -0,0 +1,5 @@
+-- Copyright 2020 Google LLC.
+-- SPDX-License-Identifier: Apache-2.0
+
+CREATE VIEW test_chrome_metric_output AS
+SELECT TestChromeMetric('test_value', 1))