Added metrics argument to headless inorder to export metrics

Summary:
This diff makes headless flipper accept `metrics` argument. Once this is passed. The headless flipper will terminate to export the metrics of the plugins, the type of the export looks like the following.

```
export type MetricType = {[metricName: string]: number};
type MetricPluginType = {[pluginID: string]: MetricType};
export type ExportMetricType = {[clientID: string]: MetricPluginType};

```

This diff, uses the store to export the metrics. I will modify the logic to accept the data which gets exported through `exportData`

Reviewed By: passy

Differential Revision: D14933499

fbshipit-source-id: dade5b7bc59ea4beb6d16c5ef471737e8597358a
This commit is contained in:
Pritesh Nandgaonkar
2019-04-25 07:34:02 -07:00
committed by Facebook Github Bot
parent 7bbb8c10c4
commit afd729deb6
5 changed files with 101 additions and 11 deletions

View File

@@ -107,6 +107,19 @@ export default class extends FlipperPlugin<State, *, PersistedState> {
responses: {},
};
static exportMetrics = (
persistedState: PersistedState,
): Promise<Map<string, number | string>> => {
const failures = Object.keys(persistedState.responses).reduce(function(
previous,
key,
) {
return previous + (persistedState.responses[key].status >= 400);
},
0);
return Promise.resolve(new Map([['NUMBER_NETWORK_FAILURES', failures]]));
};
static persistedStateReducer = (
persistedState: PersistedState,
method: string,