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

## Unreleased

### Fixes

* Filter out app starts with more than 60s (#895)

## 6.6.0

### Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import '../sentry_native_channel.dart';
/// EventProcessor that enriches [SentryTransaction] objects with app start
/// measurement.
class NativeAppStartEventProcessor extends EventProcessor {
/// We filter out App starts more than 60s
static const _maxAppStartMillis = 60000;

NativeAppStartEventProcessor(
this._native,
);
Expand All @@ -22,9 +25,22 @@ class NativeAppStartEventProcessor extends EventProcessor {
event is SentryTransaction &&
!_native.didFetchAppStart) {
final nativeAppStart = await _native.fetchNativeAppStart();
if (nativeAppStart != null) {
event.measurements.add(nativeAppStart.toMeasurement(appStartEnd));
if (nativeAppStart == null) {
return event;
}
final measurement = nativeAppStart.toMeasurement(appStartEnd);
// We filter out app start more than 60s.
// This could be due to many different reasons.
// If you do the manual init and init the SDK too late and it does not
// compute the app start end in the very first Screen.
// If the process starts but the App isn't in the foreground.
// If the system forked the process earlier to accelerate the app start.
// And some unknown reasons that could not be reproduced.
// We've seen app starts with hours, days and even months.
if (measurement.value >= _maxAppStartMillis) {
return event;
}
event.measurements.add(measurement);
}
return event;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,22 @@ void main() {
expect(secondEnriched.measurements.length, 2);
expect(secondEnriched.measurements.contains(measurement), true);
});

test('native app start measurement not added if more than 60s', () async {
fixture.options.autoAppStart = false;
fixture.native.appStartEnd = DateTime.fromMillisecondsSinceEpoch(60001);
fixture.wrapper.nativeAppStart = NativeAppStart(0, true);

fixture.getNativeAppStartIntegration().call(MockHub(), fixture.options);

final tracer = fixture.createTracer();
final transaction = SentryTransaction(tracer);

final processor = fixture.options.eventProcessors.first;
final enriched = await processor.apply(transaction) as SentryTransaction;

expect(enriched.measurements.isEmpty, true);
});
});
}

Expand Down