From 475dfa6891932a041694d88db605330c6944e655 Mon Sep 17 00:00:00 2001 From: Bertrand SIMONNET Date: Tue, 4 Aug 2015 14:10:10 -0700 Subject: [PATCH] metrics: Remove send to autotest. This code is no longer used and can be removed. BUG: 22879597 Change-Id: I59a51597f4c3699aa7952b0553144ad0ee03ebde --- metrics/include/metrics/metrics_library.h | 5 +- metrics/metrics_client.cc | 61 +++++++---------------- metrics/metrics_library.cc | 12 ----- 3 files changed, 20 insertions(+), 58 deletions(-) diff --git a/metrics/include/metrics/metrics_library.h b/metrics/include/metrics/metrics_library.h index 7508100f8..1c124d2ae 100644 --- a/metrics/include/metrics/metrics_library.h +++ b/metrics/include/metrics/metrics_library.h @@ -26,7 +26,7 @@ class MetricsLibraryInterface { virtual ~MetricsLibraryInterface() {} }; -// Library used to send metrics to both Autotest and Chrome/UMA. +// Library used to send metrics to Chrome/UMA. class MetricsLibrary : public MetricsLibraryInterface { public: MetricsLibrary(); @@ -107,9 +107,6 @@ class MetricsLibrary : public MetricsLibraryInterface { // number in the histograms dashboard). bool SendCrosEventToUMA(const std::string& event); - // Sends to Autotest and returns true on success. - static bool SendToAutotest(const std::string& name, int value); - private: friend class CMetricsLibraryTest; friend class MetricsLibraryTest; diff --git a/metrics/metrics_client.cc b/metrics/metrics_client.cc index bbe9dcda2..b587e3a24 100644 --- a/metrics/metrics_client.cc +++ b/metrics/metrics_client.cc @@ -19,17 +19,15 @@ enum Mode { void ShowUsage() { fprintf(stderr, - "Usage: metrics_client [-ab] [-t] name sample min max nbuckets\n" - " metrics_client [-ab] -e name sample max\n" - " metrics_client [-ab] -s name sample\n" - " metrics_client [-ab] -v event\n" + "Usage: metrics_client [-t] name sample min max nbuckets\n" + " metrics_client -e name sample max\n" + " metrics_client -s name sample\n" + " metrics_client -v event\n" " metrics_client -u action\n" " metrics_client [-cg]\n" "\n" - " default: send metric with integer values to Chrome only\n" + " default: send metric with integer values \n" " |min| > 0, |min| <= sample < |max|\n" - " -a: send metric (name/sample) to Autotest only\n" - " -b: send metric to both Chrome and Autotest\n" " -c: return exit status 0 if user consents to stats, 1 otherwise,\n" " in guest mode always return 1\n" " -e: send linear/enumeration histogram data\n" @@ -64,9 +62,7 @@ static double ParseDouble(const char *arg) { static int SendStats(char* argv[], int name_index, enum Mode mode, - bool secs_to_msecs, - bool send_to_autotest, - bool send_to_chrome) { + bool secs_to_msecs) { const char* name = argv[name_index]; int sample; if (secs_to_msecs) { @@ -75,25 +71,18 @@ static int SendStats(char* argv[], sample = ParseInt(argv[name_index + 1]); } - // Send metrics - if (send_to_autotest) { - MetricsLibrary::SendToAutotest(name, sample); - } - - if (send_to_chrome) { - MetricsLibrary metrics_lib; - metrics_lib.Init(); - if (mode == kModeSendSparseSample) { - metrics_lib.SendSparseToUMA(name, sample); - } else if (mode == kModeSendEnumSample) { - int max = ParseInt(argv[name_index + 2]); - metrics_lib.SendEnumToUMA(name, sample, max); - } else { - int min = ParseInt(argv[name_index + 2]); - int max = ParseInt(argv[name_index + 3]); - int nbuckets = ParseInt(argv[name_index + 4]); - metrics_lib.SendToUMA(name, sample, min, max, nbuckets); - } + MetricsLibrary metrics_lib; + metrics_lib.Init(); + if (mode == kModeSendSparseSample) { + metrics_lib.SendSparseToUMA(name, sample); + } else if (mode == kModeSendEnumSample) { + int max = ParseInt(argv[name_index + 2]); + metrics_lib.SendEnumToUMA(name, sample, max); + } else { + int min = ParseInt(argv[name_index + 2]); + int max = ParseInt(argv[name_index + 3]); + int nbuckets = ParseInt(argv[name_index + 4]); + metrics_lib.SendToUMA(name, sample, min, max, nbuckets); } return 0; } @@ -133,22 +122,12 @@ static int IsGuestMode() { int main(int argc, char** argv) { enum Mode mode = kModeSendSample; - bool send_to_autotest = false; - bool send_to_chrome = true; bool secs_to_msecs = false; // Parse arguments int flag; while ((flag = getopt(argc, argv, "abcegstuv")) != -1) { switch (flag) { - case 'a': - send_to_autotest = true; - send_to_chrome = false; - break; - case 'b': - send_to_chrome = true; - send_to_autotest = true; - break; case 'c': mode = kModeHasConsent; break; @@ -203,9 +182,7 @@ int main(int argc, char** argv) { return SendStats(argv, arg_index, mode, - secs_to_msecs, - send_to_autotest, - send_to_chrome); + secs_to_msecs); case kModeSendUserAction: return SendUserAction(argv, arg_index); case kModeSendCrosEvent: diff --git a/metrics/metrics_library.cc b/metrics/metrics_library.cc index db7e7d373..f777f2823 100644 --- a/metrics/metrics_library.cc +++ b/metrics/metrics_library.cc @@ -128,18 +128,6 @@ void MetricsLibrary::Init() { uma_events_file_ = metrics::kMetricsEventsFilePath; } -bool MetricsLibrary::SendToAutotest(const std::string& name, int value) { - FILE* autotest_file = fopen(kAutotestPath, "a+"); - if (autotest_file == nullptr) { - PLOG(ERROR) << kAutotestPath << ": fopen"; - return false; - } - - fprintf(autotest_file, "%s=%d\n", name.c_str(), value); - fclose(autotest_file); - return true; -} - bool MetricsLibrary::SendToUMA(const std::string& name, int sample, int min,