Skip to content

Commit 5f555b2

Browse files
denraseDenis Andrašec
andauthored
Feat: Configure idle transaction duration (#705)
Co-authored-by: Denis Andrašec <[email protected]>
1 parent 11b55fb commit 5f555b2

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Unreleased
22

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

56
# 6.3.0-beta.2

flutter/lib/src/navigation/sentry_navigator_observer.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ typedef AdditionalInfoExtractor = Map<String, dynamic>? Function(
4141
/// ```
4242
///
4343
/// The option [enableAutoTransactions] is enabled by default. For every new
44-
/// route a transaction is started. It's automatically finished after 3 seconds
45-
/// or when all child spans are finished, if those happen to take longer. The
46-
/// transaction will be set to [Scope.span] if the latter is empty.
44+
/// route a transaction is started. It's automatically finished after
45+
/// [autoFinishAfter] duration or when all child spans are finished,
46+
/// if those happen to take longer. The transaction will be set to [Scope.span]
47+
/// if the latter is empty.
4748
///
4849
/// Enabling the [setRouteNameAsTransaction] option overrides the current
4950
/// [Scope.transaction] which will also override the name of the current
@@ -57,17 +58,20 @@ class SentryNavigatorObserver extends RouteObserver<PageRoute<dynamic>> {
5758
SentryNavigatorObserver({
5859
Hub? hub,
5960
bool enableAutoTransactions = true,
61+
Duration autoFinishAfter = const Duration(seconds: 3),
6062
bool setRouteNameAsTransaction = false,
6163
RouteNameExtractor? routeNameExtractor,
6264
AdditionalInfoExtractor? additionalInfoProvider,
6365
}) : _hub = hub ?? HubAdapter(),
6466
_enableAutoTransactions = enableAutoTransactions,
67+
_autoFinishAfter = autoFinishAfter,
6568
_setRouteNameAsTransaction = setRouteNameAsTransaction,
6669
_routeNameExtractor = routeNameExtractor,
6770
_additionalInfoProvider = additionalInfoProvider;
6871

6972
final Hub _hub;
7073
final bool _enableAutoTransactions;
74+
final Duration _autoFinishAfter;
7175
final bool _setRouteNameAsTransaction;
7276
final RouteNameExtractor? _routeNameExtractor;
7377
final AdditionalInfoExtractor? _additionalInfoProvider;
@@ -152,7 +156,7 @@ class SentryNavigatorObserver extends RouteObserver<PageRoute<dynamic>> {
152156
name,
153157
'navigation',
154158
waitForChildren: true,
155-
autoFinishAfter: Duration(seconds: 3),
159+
autoFinishAfter: _autoFinishAfter,
156160
);
157161
if (arguments != null) {
158162
_transaction?.setData('route_settings_arguments', arguments);

flutter/test/sentry_navigator_observer_test.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,18 @@ void main() {
3939
final hub = _MockHub();
4040
final span = MockNoOpSentrySpan();
4141
_whenAnyStart(hub, span);
42-
final sut = fixture.getSut(hub: hub);
42+
final sut = fixture.getSut(
43+
hub: hub,
44+
autoFinishAfter: Duration(seconds: 5),
45+
);
4346

4447
sut.didPush(currentRoute, null);
4548

4649
verify(hub.startTransaction(
4750
'Current Route',
4851
'navigation',
4952
waitForChildren: true,
50-
autoFinishAfter: Duration(seconds: 3),
53+
autoFinishAfter: Duration(seconds: 5),
5154
));
5255

5356
hub.configureScope((scope) {
@@ -583,13 +586,15 @@ class Fixture {
583586
SentryNavigatorObserver getSut({
584587
required Hub hub,
585588
bool enableAutoTransactions = true,
589+
Duration autoFinishAfter = const Duration(seconds: 3),
586590
bool setRouteNameAsTransaction = false,
587591
RouteNameExtractor? routeNameExtractor,
588592
AdditionalInfoExtractor? additionalInfoProvider,
589593
}) {
590594
return SentryNavigatorObserver(
591595
hub: hub,
592596
enableAutoTransactions: enableAutoTransactions,
597+
autoFinishAfter: autoFinishAfter,
593598
setRouteNameAsTransaction: setRouteNameAsTransaction,
594599
routeNameExtractor: routeNameExtractor,
595600
additionalInfoProvider: additionalInfoProvider,

0 commit comments

Comments
 (0)