Distinguish between failures and things that we knowingly dont support

Summary:
A lot of the failures in the dashboard are due to unsupported android devices.

We can track this individually, but it shouldn't be affecting how reliable we think things are.

This adds an Error type, that when thrown, adds an extra field to log messages to specify that it's a known incompatibility.

Reviewed By: passy

Differential Revision: D15394863

fbshipit-source-id: 9d7948fbb8c94bd7a64434496e10392532a61eed
This commit is contained in:
John Knox
2019-05-28 04:17:24 -07:00
committed by Facebook Github Bot
parent a64a2a31e5
commit e1aa6c4cd8
2 changed files with 28 additions and 5 deletions

View File

@@ -11,6 +11,7 @@
* arguments.
*/
import {getAdbClient} from './adbClient';
import {UnsupportedError} from './metrics';
const adbkit = require('adbkit-fb');
const allowedAppNameRegex = /^[a-zA-Z0-9._\-]+$/;
@@ -89,7 +90,7 @@ function executeCommandAsApp(
);
}
if (output.toLowerCase().match(operationNotPermittedRegex)) {
throw new Error(
throw new UnsupportedError(
`Your android device (${deviceId}) does not support the adb shell run-as command. We're tracking this at https://github.com/facebook/flipper/issues/92`,
);
}

View File

@@ -7,6 +7,12 @@
import {getInstance} from '../fb-stubs/Logger';
export class UnsupportedError extends Error {
constructor(message: string) {
super(message);
}
}
/*
* Wraps a Promise, preserving it's functionality but logging the success or
failure state of it, with a given name, based on whether it's fulfilled or
@@ -24,7 +30,11 @@ export function reportPlatformFailures<T>(
return fulfilledValue;
},
rejectionReason => {
logPlatformSuccessRate(name, {isSuccess: false, error: rejectionReason});
logPlatformSuccessRate(name, {
isSuccess: false,
supportedOperation: !(rejectionReason instanceof UnsupportedError),
error: rejectionReason,
});
return Promise.reject(rejectionReason);
},
);
@@ -50,6 +60,7 @@ export function reportPluginFailures<T>(
rejectionReason => {
logPluginSuccessRate(name, plugin, {
isSuccess: false,
supportedOperation: !(rejectionReason instanceof UnsupportedError),
error: rejectionReason,
});
return Promise.reject(rejectionReason);
@@ -70,12 +81,18 @@ export function tryCatchReportPlatformFailures<T>(
logPlatformSuccessRate(name, {isSuccess: true});
return result;
} catch (e) {
logPlatformSuccessRate(name, {isSuccess: false, error: e});
logPlatformSuccessRate(name, {
isSuccess: false,
supportedOperation: !(e instanceof UnsupportedError),
error: e,
});
throw e;
}
}
type Result = {isSuccess: true} | {isSuccess: false, error: any};
type Result =
| {isSuccess: true}
| {isSuccess: false, supportedOperation: boolean, error: any};
function logPlatformSuccessRate(name: string, result: Result) {
if (result.isSuccess) {
@@ -83,6 +100,7 @@ function logPlatformSuccessRate(name: string, result: Result) {
} else {
getInstance().track('success-rate', name, {
value: 0,
supportedOperation: result.supportedOperation ? 1 : 0,
error: extractMessage(result.error),
});
}
@@ -95,7 +113,11 @@ function logPluginSuccessRate(name: string, plugin: string, result: Result) {
getInstance().track(
'success-rate',
name,
{value: 0, error: extractMessage(result.error)},
{
value: 0,
supportedOperation: result.supportedOperation ? 1 : 0,
error: extractMessage(result.error),
},
plugin,
);
}