Skip to content
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
3 changes: 2 additions & 1 deletion src/libs/actions/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Performance from '@libs/Performance';
import {isPublicRoom, isValidReport} from '@libs/ReportUtils';
import {isLoggingInAsNewUser as isLoggingInAsNewUserSessionUtils} from '@libs/SessionUtils';
import {clearSoundAssetsCache} from '@libs/Sound';
import {endSpan, getSpan, startSpan} from '@libs/telemetry/activeSpans';
import {cancelAllSpans, endSpan, getSpan, startSpan} from '@libs/telemetry/activeSpans';
import CONST from '@src/CONST';
import type {OnyxKey} from '@src/ONYXKEYS';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -238,6 +238,7 @@ AppState.addEventListener('change', (nextAppState) => {
if (nextAppState.match(/inactive|background/) && appState === 'active') {
Log.info('Flushing logs as app is going inactive', true, {}, true);
saveCurrentPathBeforeBackground();
cancelAllSpans();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically for web we are cancelling the spans when the user changes to another tab, and that is not ideal, as that is a common flow and the app is still loading in the background right?

Would it be possible to not cancel on tab change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be no spans running in the background thought as you're not actively interacting with the app. The JS thread can be throttled and that is something we simply want to discard regardless of the platform.
Unless, you can run into a really weird cancellation in a web build from this branch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The biggest span could be the app opening, and playing the devil's advocate I can imagine we can get very few spans being recorded if people have to wait 10s+ so they naturally switch between the apps.

That is still worth in my opinion, and we can later think of excluding this one metrics if it proves to be true.

}
appState = nextAppState;
});
Expand Down
8 changes: 7 additions & 1 deletion src/libs/telemetry/activeSpans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,14 @@ function cancelSpan(spanId: string) {
endSpan(spanId);
}

function cancelAllSpans() {
for (const [spanId] of activeSpans.entries()) {
cancelSpan(spanId);
}
}

function getSpan(spanId: string) {
return activeSpans.get(spanId);
}

export {startSpan, endSpan, getSpan, cancelSpan};
export {startSpan, endSpan, getSpan, cancelSpan, cancelAllSpans};
Loading