am 6ada1665: Merge "metrics: Remove send to autotest."
* commit '6ada1665c9b3f6ffea34d0c15ba9be96d7ff58a8': metrics: Remove send to autotest.
This commit is contained in:
commit
7d41a8c8d0
3 changed files with 20 additions and 58 deletions
|
|
@ -26,7 +26,7 @@ class MetricsLibraryInterface {
|
||||||
virtual ~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 {
|
class MetricsLibrary : public MetricsLibraryInterface {
|
||||||
public:
|
public:
|
||||||
MetricsLibrary();
|
MetricsLibrary();
|
||||||
|
|
@ -107,9 +107,6 @@ class MetricsLibrary : public MetricsLibraryInterface {
|
||||||
// number in the histograms dashboard).
|
// number in the histograms dashboard).
|
||||||
bool SendCrosEventToUMA(const std::string& event);
|
bool SendCrosEventToUMA(const std::string& event);
|
||||||
|
|
||||||
// Sends to Autotest and returns true on success.
|
|
||||||
static bool SendToAutotest(const std::string& name, int value);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class CMetricsLibraryTest;
|
friend class CMetricsLibraryTest;
|
||||||
friend class MetricsLibraryTest;
|
friend class MetricsLibraryTest;
|
||||||
|
|
|
||||||
|
|
@ -19,17 +19,15 @@ enum Mode {
|
||||||
|
|
||||||
void ShowUsage() {
|
void ShowUsage() {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Usage: metrics_client [-ab] [-t] name sample min max nbuckets\n"
|
"Usage: metrics_client [-t] name sample min max nbuckets\n"
|
||||||
" metrics_client [-ab] -e name sample max\n"
|
" metrics_client -e name sample max\n"
|
||||||
" metrics_client [-ab] -s name sample\n"
|
" metrics_client -s name sample\n"
|
||||||
" metrics_client [-ab] -v event\n"
|
" metrics_client -v event\n"
|
||||||
" metrics_client -u action\n"
|
" metrics_client -u action\n"
|
||||||
" metrics_client [-cg]\n"
|
" metrics_client [-cg]\n"
|
||||||
"\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"
|
" |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"
|
" -c: return exit status 0 if user consents to stats, 1 otherwise,\n"
|
||||||
" in guest mode always return 1\n"
|
" in guest mode always return 1\n"
|
||||||
" -e: send linear/enumeration histogram data\n"
|
" -e: send linear/enumeration histogram data\n"
|
||||||
|
|
@ -64,9 +62,7 @@ static double ParseDouble(const char *arg) {
|
||||||
static int SendStats(char* argv[],
|
static int SendStats(char* argv[],
|
||||||
int name_index,
|
int name_index,
|
||||||
enum Mode mode,
|
enum Mode mode,
|
||||||
bool secs_to_msecs,
|
bool secs_to_msecs) {
|
||||||
bool send_to_autotest,
|
|
||||||
bool send_to_chrome) {
|
|
||||||
const char* name = argv[name_index];
|
const char* name = argv[name_index];
|
||||||
int sample;
|
int sample;
|
||||||
if (secs_to_msecs) {
|
if (secs_to_msecs) {
|
||||||
|
|
@ -75,25 +71,18 @@ static int SendStats(char* argv[],
|
||||||
sample = ParseInt(argv[name_index + 1]);
|
sample = ParseInt(argv[name_index + 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send metrics
|
MetricsLibrary metrics_lib;
|
||||||
if (send_to_autotest) {
|
metrics_lib.Init();
|
||||||
MetricsLibrary::SendToAutotest(name, sample);
|
if (mode == kModeSendSparseSample) {
|
||||||
}
|
metrics_lib.SendSparseToUMA(name, sample);
|
||||||
|
} else if (mode == kModeSendEnumSample) {
|
||||||
if (send_to_chrome) {
|
int max = ParseInt(argv[name_index + 2]);
|
||||||
MetricsLibrary metrics_lib;
|
metrics_lib.SendEnumToUMA(name, sample, max);
|
||||||
metrics_lib.Init();
|
} else {
|
||||||
if (mode == kModeSendSparseSample) {
|
int min = ParseInt(argv[name_index + 2]);
|
||||||
metrics_lib.SendSparseToUMA(name, sample);
|
int max = ParseInt(argv[name_index + 3]);
|
||||||
} else if (mode == kModeSendEnumSample) {
|
int nbuckets = ParseInt(argv[name_index + 4]);
|
||||||
int max = ParseInt(argv[name_index + 2]);
|
metrics_lib.SendToUMA(name, sample, min, max, nbuckets);
|
||||||
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -133,22 +122,12 @@ static int IsGuestMode() {
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
enum Mode mode = kModeSendSample;
|
enum Mode mode = kModeSendSample;
|
||||||
bool send_to_autotest = false;
|
|
||||||
bool send_to_chrome = true;
|
|
||||||
bool secs_to_msecs = false;
|
bool secs_to_msecs = false;
|
||||||
|
|
||||||
// Parse arguments
|
// Parse arguments
|
||||||
int flag;
|
int flag;
|
||||||
while ((flag = getopt(argc, argv, "abcegstuv")) != -1) {
|
while ((flag = getopt(argc, argv, "abcegstuv")) != -1) {
|
||||||
switch (flag) {
|
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':
|
case 'c':
|
||||||
mode = kModeHasConsent;
|
mode = kModeHasConsent;
|
||||||
break;
|
break;
|
||||||
|
|
@ -203,9 +182,7 @@ int main(int argc, char** argv) {
|
||||||
return SendStats(argv,
|
return SendStats(argv,
|
||||||
arg_index,
|
arg_index,
|
||||||
mode,
|
mode,
|
||||||
secs_to_msecs,
|
secs_to_msecs);
|
||||||
send_to_autotest,
|
|
||||||
send_to_chrome);
|
|
||||||
case kModeSendUserAction:
|
case kModeSendUserAction:
|
||||||
return SendUserAction(argv, arg_index);
|
return SendUserAction(argv, arg_index);
|
||||||
case kModeSendCrosEvent:
|
case kModeSendCrosEvent:
|
||||||
|
|
|
||||||
|
|
@ -128,18 +128,6 @@ void MetricsLibrary::Init() {
|
||||||
uma_events_file_ = metrics::kMetricsEventsFilePath;
|
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,
|
bool MetricsLibrary::SendToUMA(const std::string& name,
|
||||||
int sample,
|
int sample,
|
||||||
int min,
|
int min,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue