Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
5c87477
didPush starts transaction
Nov 24, 2021
e72ccc6
didPush finishes previous transaction
Nov 24, 2021
ff0896e
fix mocking
Nov 25, 2021
adde75d
test finish with idle timer
Nov 25, 2021
7a0c96b
finish transaction on pop
Nov 25, 2021
0f79e44
check if span status is set
Nov 25, 2021
0bbce7a
test setting of arguments
Nov 25, 2021
45186fe
format
Nov 25, 2021
deef4a9
re-start previous
Nov 25, 2021
1e204c0
dont start transaction with empty name
Nov 25, 2021
0dd396c
dont expose options
Nov 25, 2021
998ee18
Update changelog
Nov 25, 2021
c3c7de8
provide opt-out of auto transactions
Nov 26, 2021
5406ad4
run format
Nov 26, 2021
75fa043
move idle timer to tracer, only start transaction if scope is not setโ€ฆ
Nov 30, 2021
f7b8417
implement waitForChildren
Nov 30, 2021
e5276c0
move finishAfter to ISentrySpan
Nov 30, 2021
97533fc
expose waitForChildren api
Dec 1, 2021
6161cb0
move finishAfter implementation out of abstract class
Dec 1, 2021
e5f8c7e
Merge branch 'main' into feat/auto-transactions
Dec 1, 2021
c003afc
add missing tests for callback on finish
Dec 1, 2021
5656aa6
move SentryTracerFinishStatus to own file
Dec 1, 2021
941d854
run format
Dec 1, 2021
3456911
propagate waitForChildren
Dec 1, 2021
c32a413
only bind to scope if scope span is null
Dec 3, 2021
5b791ad
format
Dec 3, 2021
90c6de3
Merge branch 'main' into feat/auto-transactions
Dec 3, 2021
22a395f
move finifhed callback to SentrySpan ctor
Dec 9, 2021
96b4a5c
update doc for enableAutoTransactions
Dec 9, 2021
762cf12
Merge branch 'main' into feat/auto-transactions
Dec 9, 2021
28bc711
remove unneccesary imports
Dec 9, 2021
c43b04b
Merge branch 'main' into feat/auto-transactions
Dec 14, 2021
ef633a0
dont call super in noop method
Dec 14, 2021
7817a28
move auto finish after duration to start transactions as param
Dec 14, 2021
835fbd3
Remove unused param
Dec 15, 2021
8bb14a4
return immed.
Dec 15, 2021
9ab1b87
Merge branch 'main' into feat/auto-transactions
Dec 15, 2021
25c1a81
Merge branch 'main' into feat/auto-transactions
Dec 15, 2021
7cdf854
no need to double check finished
Dec 15, 2021
2251af2
use more descriptive changelog
Dec 15, 2021
2f268a3
use current span instead of new transaction for sample
marandaneto Dec 15, 2021
3063a14
fix
marandaneto Dec 15, 2021
b369fc2
fix test
marandaneto Dec 15, 2021
4d8e600
fix tests
marandaneto Dec 15, 2021
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
Prev Previous commit
Next Next commit
didPush finishes previous transaction
  • Loading branch information
Denis Andraลกec authored and Denis Andraลกec committed Nov 24, 2021
commit e72ccc651a60375eda5c67cb5597249d77f1c67f
5 changes: 5 additions & 0 deletions flutter/lib/src/navigation/sentry_navigator_observer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class SentryNavigatorObserver extends RouteObserver<PageRoute<dynamic>> {
from: previousRoute?.settings,
to: route.settings,
);
_finishTransaction();
_startTransaction(route.settings.name, route.settings.arguments);
}

Expand Down Expand Up @@ -114,6 +115,10 @@ class SentryNavigatorObserver extends RouteObserver<PageRoute<dynamic>> {
}
}

Future<void> _finishTransaction() async {
//_transaction?.status ??= SpanStatus.ok();
return await _transaction?.finish();
}
}

/// This class makes it easier to record breadcrumbs for events of Flutters
Expand Down
2 changes: 1 addition & 1 deletion flutter/test/mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:sentry/src/sentry_user_feedback.dart';

const fakeDsn = 'https://[email protected]/1234567';

@GenerateMocks([Hub, Transport])
@GenerateMocks([Hub, Transport, NoOpSentrySpan])
void main() {}

class MockPlatform implements Platform {
Expand Down
72 changes: 72 additions & 0 deletions flutter/test/mocks.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'dart:async' as _i5;

import 'package:mockito/mockito.dart' as _i1;
import 'package:sentry/src/hub.dart' as _i3;
import 'package:sentry/src/noop_sentry_span.dart' as _i10;
import 'package:sentry/src/protocol.dart' as _i2;
import 'package:sentry/src/sentry_client.dart' as _i7;
import 'package:sentry/src/sentry_envelope.dart' as _i9;
Expand All @@ -28,6 +29,14 @@ class _FakeHub_1 extends _i1.Fake implements _i3.Hub {}

class _FakeISentrySpan_2 extends _i1.Fake implements _i4.ISentrySpan {}

class _FakeSentrySpanContext_3 extends _i1.Fake
implements _i4.SentrySpanContext {}

class _FakeDateTime_4 extends _i1.Fake implements DateTime {}

class _FakeSentryTraceHeader_5 extends _i1.Fake
implements _i2.SentryTraceHeader {}

/// A class which mocks [Hub].
///
/// See the documentation for Mockito's code generation for more information.
Expand Down Expand Up @@ -174,3 +183,66 @@ class MockTransport extends _i1.Mock implements _i8.Transport {
@override
String toString() => super.toString();
}

/// A class which mocks [NoOpSentrySpan].
///
/// See the documentation for Mockito's code generation for more information.
class MockNoOpSentrySpan extends _i1.Mock implements _i10.NoOpSentrySpan {
MockNoOpSentrySpan() {
_i1.throwOnMissingStub(this);
}

@override
_i4.SentrySpanContext get context =>
(super.noSuchMethod(Invocation.getter(#context),
returnValue: _FakeSentrySpanContext_3()) as _i4.SentrySpanContext);
@override
DateTime get startTimestamp =>
(super.noSuchMethod(Invocation.getter(#startTimestamp),
returnValue: _FakeDateTime_4()) as DateTime);
@override
bool get finished =>
(super.noSuchMethod(Invocation.getter(#finished), returnValue: false)
as bool);
@override
set throwable(dynamic throwable) =>
super.noSuchMethod(Invocation.setter(#throwable, throwable),
returnValueForMissingStub: null);
@override
set status(_i2.SpanStatus? status) =>
super.noSuchMethod(Invocation.setter(#status, status),
returnValueForMissingStub: null);
@override
_i5.Future<void> finish({_i2.SpanStatus? status}) =>
(super.noSuchMethod(Invocation.method(#finish, [], {#status: status}),
returnValue: Future<void>.value(),
returnValueForMissingStub: Future<void>.value()) as _i5.Future<void>);
@override
void removeData(String? key) =>
super.noSuchMethod(Invocation.method(#removeData, [key]),
returnValueForMissingStub: null);
@override
void removeTag(String? key) =>
super.noSuchMethod(Invocation.method(#removeTag, [key]),
returnValueForMissingStub: null);
@override
void setData(String? key, dynamic value) =>
super.noSuchMethod(Invocation.method(#setData, [key, value]),
returnValueForMissingStub: null);
@override
void setTag(String? key, String? value) =>
super.noSuchMethod(Invocation.method(#setTag, [key, value]),
returnValueForMissingStub: null);
@override
_i4.ISentrySpan startChild(String? operation, {String? description}) =>
(super.noSuchMethod(
Invocation.method(
#startChild, [operation], {#description: description}),
returnValue: _FakeISentrySpan_2()) as _i4.ISentrySpan);
@override
_i2.SentryTraceHeader toSentryTrace() =>
(super.noSuchMethod(Invocation.method(#toSentryTrace, []),
returnValue: _FakeSentryTraceHeader_5()) as _i2.SentryTraceHeader);
@override
String toString() => super.toString();
}
12 changes: 12 additions & 0 deletions flutter/test/sentry_navigator_observer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,19 @@ void main() {
});

test('didPush finishes previous transaction', () {
final firstRoute = route(RouteSettings(name: 'First Route'));
final secondRoute = route(RouteSettings(name: 'Second Route'));

final hub = MockHub();
final span = MockNoOpSentrySpan();
when(hub.startTransaction('First Route', 'ui.load', description: null, bindToScope: true, customSamplingContext: null)).thenReturn(span);
when(hub.startTransaction('Second Route', 'ui.load', description: null, bindToScope: true, customSamplingContext: null)).thenReturn(NoOpSentrySpan());
final sut = fixture.getSut(hub: hub, setRouteNameAsTransaction: false);

sut.didPush(firstRoute, null);
sut.didPush(secondRoute, firstRoute);

verify(span.finish());
});
});

Expand Down