Skip to content

Commit

Permalink
fix: event processor failed to stop processing (#2289)
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind authored Sep 13, 2024
1 parent 09c1f55 commit 7d5e695
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions dart/lib/src/sentry_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ class SentryClient {
count: spanCountBeforeEventProcessors + 1);
}
_options.logger(SentryLevel.debug, 'Event was dropped by a processor');
break;
} else if (event is SentryTransaction &&
processedEvent is SentryTransaction) {
// If event processor removed only some spans we still report them as dropped
Expand Down
14 changes: 12 additions & 2 deletions dart/test/sentry_client_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1249,6 +1249,7 @@ void main() {
});

test('thrown error is handled', () async {
fixture.options.automatedTestMode = false;
final exception = Exception("before send exception");
final beforeSendTransactionCallback = (SentryTransaction event) {
throw exception;
Expand Down Expand Up @@ -1311,6 +1312,7 @@ void main() {
});

test('thrown error is handled', () async {
fixture.options.automatedTestMode = false;
final exception = Exception("before send exception");
final beforeSendCallback = (SentryEvent event, Hint hint) {
throw exception;
Expand Down Expand Up @@ -1604,14 +1606,21 @@ void main() {
});

test('record event processor dropping event', () async {
final client = fixture.getSut(eventProcessor: DropAllEventProcessor());
bool secondProcessorCalled = false;
fixture.options.addEventProcessor(DropAllEventProcessor());
fixture.options.addEventProcessor(FunctionEventProcessor((event, hint) {
secondProcessorCalled = true;
return event;
}));
final client = fixture.getSut();

await client.captureEvent(fakeEvent);

expect(fixture.recorder.discardedEvents.first.reason,
DiscardReason.eventProcessor);
expect(
fixture.recorder.discardedEvents.first.category, DataCategory.error);
expect(secondProcessorCalled, isFalse);
});

test('record event processor dropping transaction', () async {
Expand Down Expand Up @@ -1885,7 +1894,8 @@ class Fixture {
final transport = MockTransport();

final options = SentryOptions(dsn: fakeDsn)
..platformChecker = MockPlatformChecker(platform: MockPlatform.iOS());
..platformChecker = MockPlatformChecker(platform: MockPlatform.iOS())
..automatedTestMode = true;

late SentryTransactionContext _context;
late SentryTracer tracer;
Expand Down

0 comments on commit 7d5e695

Please sign in to comment.