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

* Feat: Configure idle transaction duration (#705)
* Fix: `maxRequestBodySize` should be `never` by default when using the FailedRequestClientAdapter directly (#701)

# 6.3.0-beta.2
Expand Down
12 changes: 8 additions & 4 deletions flutter/lib/src/navigation/sentry_navigator_observer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ typedef AdditionalInfoExtractor = Map<String, dynamic>? Function(
/// ```
///
/// The option [enableAutoTransactions] is enabled by default. For every new
/// route a transaction is started. It's automatically finished after 3 seconds
/// or when all child spans are finished, if those happen to take longer. The
/// transaction will be set to [Scope.span] if the latter is empty.
/// route a transaction is started. It's automatically finished after
/// [autoFinishAfter] duration or when all child spans are finished,
/// if those happen to take longer. The transaction will be set to [Scope.span]
/// if the latter is empty.
///
/// Enabling the [setRouteNameAsTransaction] option overrides the current
/// [Scope.transaction] which will also override the name of the current
Expand All @@ -57,17 +58,20 @@ class SentryNavigatorObserver extends RouteObserver<PageRoute<dynamic>> {
SentryNavigatorObserver({
Hub? hub,
bool enableAutoTransactions = true,
Duration autoFinishAfter = const Duration(seconds: 3),
bool setRouteNameAsTransaction = false,
RouteNameExtractor? routeNameExtractor,
AdditionalInfoExtractor? additionalInfoProvider,
}) : _hub = hub ?? HubAdapter(),
_enableAutoTransactions = enableAutoTransactions,
_autoFinishAfter = autoFinishAfter,
_setRouteNameAsTransaction = setRouteNameAsTransaction,
_routeNameExtractor = routeNameExtractor,
_additionalInfoProvider = additionalInfoProvider;

final Hub _hub;
final bool _enableAutoTransactions;
final Duration _autoFinishAfter;
final bool _setRouteNameAsTransaction;
final RouteNameExtractor? _routeNameExtractor;
final AdditionalInfoExtractor? _additionalInfoProvider;
Expand Down Expand Up @@ -152,7 +156,7 @@ class SentryNavigatorObserver extends RouteObserver<PageRoute<dynamic>> {
name,
'navigation',
waitForChildren: true,
autoFinishAfter: Duration(seconds: 3),
autoFinishAfter: _autoFinishAfter,
);
if (arguments != null) {
_transaction?.setData('route_settings_arguments', arguments);
Expand Down
9 changes: 7 additions & 2 deletions flutter/test/sentry_navigator_observer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,18 @@ void main() {
final hub = _MockHub();
final span = MockNoOpSentrySpan();
_whenAnyStart(hub, span);
final sut = fixture.getSut(hub: hub);
final sut = fixture.getSut(
hub: hub,
autoFinishAfter: Duration(seconds: 5),
);

sut.didPush(currentRoute, null);

verify(hub.startTransaction(
'Current Route',
'navigation',
waitForChildren: true,
autoFinishAfter: Duration(seconds: 3),
autoFinishAfter: Duration(seconds: 5),
));

hub.configureScope((scope) {
Expand Down Expand Up @@ -583,13 +586,15 @@ class Fixture {
SentryNavigatorObserver getSut({
required Hub hub,
bool enableAutoTransactions = true,
Duration autoFinishAfter = const Duration(seconds: 3),
bool setRouteNameAsTransaction = false,
RouteNameExtractor? routeNameExtractor,
AdditionalInfoExtractor? additionalInfoProvider,
}) {
return SentryNavigatorObserver(
hub: hub,
enableAutoTransactions: enableAutoTransactions,
autoFinishAfter: autoFinishAfter,
setRouteNameAsTransaction: setRouteNameAsTransaction,
routeNameExtractor: routeNameExtractor,
additionalInfoProvider: additionalInfoProvider,
Expand Down