Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA] Make Firebase traces an opt-in feature of global Timing class #4697

Merged
merged 2 commits into from
Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/libs/actions/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import * as API from '../API';
import CONST from '../../CONST';
import Log from '../Log';
import CONFIG from '../../CONFIG';
import Firebase from '../Firebase';
import ROUTES from '../../ROUTES';
import {printPerformanceMetrics} from '../Performance';
import canCapturePerformanceMetrics from '../canCapturePerformanceMetrics';
import Timing from './Timing';

let currentUserAccountID;
Onyx.connect({
Expand Down Expand Up @@ -60,7 +60,7 @@ function setSidebarLoaded() {
}

Onyx.set(ONYXKEYS.IS_SIDEBAR_LOADED, true);
Firebase.stopTrace(CONST.TIMING.SIDEBAR_LOADED);
Timing.end(CONST.TIMING.SIDEBAR_LOADED);

if (!canCapturePerformanceMetrics()) {
return;
Expand Down
20 changes: 17 additions & 3 deletions src/libs/actions/Timing.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
import getPlatform from '../getPlatform';
import {Graphite_Timer} from '../API';
import {isDevelopment} from '../Environment/Environment';
import Firebase from '../Firebase';

let timestampData = {};

/**
* Start a performance timing measurement
*
* @param {String} eventName
* @param {Boolean} shouldUseFirebase - adds an additional trace in Firebase
*/
function start(eventName) {
timestampData[eventName] = Date.now();
function start(eventName, shouldUseFirebase = false) {
timestampData[eventName] = {startTime: Date.now(), shouldUseFirebase};

if (!shouldUseFirebase) {
return;
}

Firebase.startTrace(eventName);
}

/**
Expand All @@ -21,7 +29,13 @@ function start(eventName) {
*/
function end(eventName, secondaryName = '') {
if (eventName in timestampData) {
const eventTime = Date.now() - timestampData[eventName];
const {startTime, shouldUseFirebase} = timestampData[eventName];
const eventTime = Date.now() - startTime;

if (shouldUseFirebase) {
Firebase.stopTrace(eventName);
}

const grafanaEventName = secondaryName
? `expensify.cash.${eventName}.${secondaryName}`
: `expensify.cash.${eventName}`;
Expand Down
Empty file removed src/libs/xhr.js
Empty file.
3 changes: 1 addition & 2 deletions src/pages/home/sidebar/SidebarScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
} from '../../../components/Icon/Expensicons';
import Permissions from '../../../libs/Permissions';
import ONYXKEYS from '../../../ONYXKEYS';
import Firebase from '../../../libs/Firebase';
import {create} from '../../../libs/actions/Policy';

const propTypes = {
Expand All @@ -50,7 +49,7 @@ class SidebarScreen extends Component {
}

componentDidMount() {
Firebase.startTrace(CONST.TIMING.SIDEBAR_LOADED);
Timing.start(CONST.TIMING.SIDEBAR_LOADED, true);
}

/**
Expand Down