Skip to content

Commit

Permalink
fix(logs): Add missing App Start logs when the span is dropped (#3861)
Browse files Browse the repository at this point in the history
  • Loading branch information
krystofwoldrich committed Jun 6, 2024
1 parent 0019f64 commit aefb75b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
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

0 comments on commit aefb75b

Please sign in to comment.