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

fix(logs): Add missing App Start logs when the span is dropped #3861

Merged
merged 3 commits into from
Jun 6, 2024
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Fix

- Add missing logs to dropped App Start spans ([#3861](https://github.com/getsentry/sentry-react-native/pull/3861))

## 5.23.0

### Features
Expand Down
12 changes: 10 additions & 2 deletions src/js/tracing/reactnativetracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,11 +422,18 @@ export class ReactNativeTracing implements Integration {

const appStart = await NATIVE.fetchNativeAppStart();

if (!appStart || appStart.didFetchAppStart) {
if (!appStart) {
logger.warn('[ReactNativeTracing] Not instrumenting App Start because native returned null.');
return;
}

if (appStart.didFetchAppStart) {
logger.warn('[ReactNativeTracing] Not instrumenting App Start because this start was already reported.');
return;
}

if (!this.useAppStartWithProfiler) {
logger.warn('[ReactNativeTracing] `Sentry.wrap` not detected, using JS context init as app start end.');
this._appStartFinishTimestamp = getTimeOriginMilliseconds() / 1000;
}

Expand All @@ -450,14 +457,15 @@ export class ReactNativeTracing implements Integration {
private _addAppStartData(transaction: IdleTransaction, appStart: NativeAppStartResponse): void {
const appStartDurationMilliseconds = this._getAppStartDurationMilliseconds(appStart);
if (!appStartDurationMilliseconds) {
logger.warn('App start was never finished.');
logger.warn('[ReactNativeTracing] App start end has not been recorded, not adding app start span.');
return;
}

// we filter out app start more than 60s.
// this could be due to many different reasons.
// we've seen app starts with hours, days and even months.
if (appStartDurationMilliseconds >= ReactNativeTracing._maxAppStart) {
logger.warn('[ReactNativeTracing] App start duration is over a minute long, not adding app start span.');
return;
}

Expand Down
Loading