metrics: Extend metric proto before registering metric
Bug:168207251
Change-Id: I36fcd17ffb23ecd1dc058b1f648d8b9f937447b6
diff --git a/src/trace_processor/trace_processor_shell.cc b/src/trace_processor/trace_processor_shell.cc
index fa644b7..870af0e 100644
--- a/src/trace_processor/trace_processor_shell.cc
+++ b/src/trace_processor/trace_processor_shell.cc
@@ -1061,15 +1061,17 @@
continue;
std::string no_ext_name = metric_or_path.substr(0, ext_idx);
- util::Status status = RegisterMetric(no_ext_name + ".sql");
+
+ // The proto must be extended before registering the metric.
+ util::Status status = ExtendMetricsProto(no_ext_name + ".proto", &pool);
if (!status.ok()) {
- return util::ErrStatus("Unable to register metric %s: %s",
+ return util::ErrStatus("Unable to extend metrics proto %s: %s",
metric_or_path.c_str(), status.c_message());
}
- status = ExtendMetricsProto(no_ext_name + ".proto", &pool);
+ status = RegisterMetric(no_ext_name + ".sql");
if (!status.ok()) {
- return util::ErrStatus("Unable to extend metrics proto %s: %s",
+ return util::ErrStatus("Unable to register metric %s: %s",
metric_or_path.c_str(), status.c_message());
}