Track time for exports
Summary: This sometimes take *A LONG* time for me, so I want to know if I'm an outlier or not. Reviewed By: jknoxville Differential Revision: D15939147 fbshipit-source-id: 9ebd3914efdd537eeadd49e522397acc97a6ff9c
This commit is contained in:
committed by
Facebook Github Bot
parent
ab6fe68a70
commit
58c66a626d
@@ -83,7 +83,11 @@ export class App extends React.Component<Props> {
|
|||||||
return <SignInSheet onHide={onHide} />;
|
return <SignInSheet onHide={onHide} />;
|
||||||
case ACTIVE_SHEET_SHARE_DATA_IN_FILE:
|
case ACTIVE_SHEET_SHARE_DATA_IN_FILE:
|
||||||
return (
|
return (
|
||||||
<ShareSheetExportFile onHide={onHide} file={this.props.exportFile} />
|
<ShareSheetExportFile
|
||||||
|
onHide={onHide}
|
||||||
|
file={this.props.exportFile}
|
||||||
|
logger={this.props.logger}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
case ACTIVE_SHEET_PLUGIN_SHEET:
|
case ACTIVE_SHEET_PLUGIN_SHEET:
|
||||||
// Currently unused.
|
// Currently unused.
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ import {
|
|||||||
Spacer,
|
Spacer,
|
||||||
} from 'flipper';
|
} from 'flipper';
|
||||||
import {reportPlatformFailures} from '../utils/metrics';
|
import {reportPlatformFailures} from '../utils/metrics';
|
||||||
|
// $FlowFixMe: Missing type defs for node built-in.
|
||||||
|
import {performance} from 'perf_hooks';
|
||||||
|
import type {Logger} from '../fb-interfaces/Logger.js';
|
||||||
import {
|
import {
|
||||||
exportStoreToFile,
|
exportStoreToFile,
|
||||||
EXPORT_FLIPPER_TRACE_EVENT,
|
EXPORT_FLIPPER_TRACE_EVENT,
|
||||||
@@ -66,6 +69,7 @@ const Padder = styled('div')(
|
|||||||
type Props = {
|
type Props = {
|
||||||
onHide: () => mixed,
|
onHide: () => mixed,
|
||||||
file: ?string,
|
file: ?string,
|
||||||
|
logger: Logger,
|
||||||
};
|
};
|
||||||
type State = {
|
type State = {
|
||||||
errorArray: Array<Error>,
|
errorArray: Array<Error>,
|
||||||
@@ -86,18 +90,23 @@ export default class ShareSheetExportFile extends Component<Props, State> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
if (!this.props.file) {
|
const mark = 'shareSheetExportFile';
|
||||||
return;
|
performance.mark(mark);
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Flow doesn't allow us to check for this earlier because `performance` is untyped
|
||||||
|
// and could presumably do anything.
|
||||||
|
if (!this.props.file) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const {errorArray} = await reportPlatformFailures(
|
const {errorArray} = await reportPlatformFailures(
|
||||||
exportStoreToFile(this.props.file, this.context.store),
|
exportStoreToFile(this.props.file, this.context.store),
|
||||||
`${EXPORT_FLIPPER_TRACE_EVENT}:UI_FILE`,
|
`${EXPORT_FLIPPER_TRACE_EVENT}:UI_FILE`,
|
||||||
);
|
);
|
||||||
this.setState({errorArray, result: {success: true, error: null}});
|
this.setState({errorArray, result: {success: true, error: null}});
|
||||||
|
this.props.logger.trackTimeSince(mark, 'export:file-success');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.setState({errorArray: [], result: {success: false, error: err}});
|
this.setState({errorArray: [], result: {success: false, error: err}});
|
||||||
|
this.props.logger.trackTimeSince(mark, 'export:file-error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import {readCurrentRevision} from './packageMetadata.js';
|
|||||||
import {tryCatchReportPlatformFailures} from './metrics';
|
import {tryCatchReportPlatformFailures} from './metrics';
|
||||||
import {promisify} from 'util';
|
import {promisify} from 'util';
|
||||||
import promiseTimeout from './promiseTimeout';
|
import promiseTimeout from './promiseTimeout';
|
||||||
import type {State} from '../reducers';
|
|
||||||
|
|
||||||
export const IMPORT_FLIPPER_TRACE_EVENT = 'import-flipper-trace';
|
export const IMPORT_FLIPPER_TRACE_EVENT = 'import-flipper-trace';
|
||||||
export const EXPORT_FLIPPER_TRACE_EVENT = 'export-flipper-trace';
|
export const EXPORT_FLIPPER_TRACE_EVENT = 'export-flipper-trace';
|
||||||
|
|||||||
Reference in New Issue
Block a user