From dd261649c976ca7c7f7b9c096b97508169cb9c40 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Wed, 7 Dec 2022 15:26:00 +0100 Subject: [PATCH 1/4] Missing slow and frozen frames for Auto transactions --- CHANGELOG.md | 4 ++++ dart/lib/src/hub_adapter.dart | 1 + dart/lib/src/protocol/sentry_span.dart | 6 ++++-- dart/lib/src/scope.dart | 5 +++-- dart/lib/src/sentry.dart | 5 +---- dart/lib/src/sentry_tracer.dart | 4 ++-- dart/test/sentry_span_test.dart | 4 ++-- .../integrations/widgets_flutter_binding_integration.dart | 7 ++++--- 8 files changed, 21 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a09a4b433..6fc5f362d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Fixes + +- Missing slow and frozen frames for Auto transactions ([#1152](https://github.com/getsentry/sentry-dart/pull/1152)) + ### Dependencies - Bump Android SDK from v6.9.1 to v6.9.2 ([#1167](https://github.com/getsentry/sentry-dart/pull/1167)) diff --git a/dart/lib/src/hub_adapter.dart b/dart/lib/src/hub_adapter.dart index 5dd32dbfe8..4df532a31b 100644 --- a/dart/lib/src/hub_adapter.dart +++ b/dart/lib/src/hub_adapter.dart @@ -129,6 +129,7 @@ class HubAdapter implements Hub { waitForChildren: waitForChildren, autoFinishAfter: autoFinishAfter, trimEnd: trimEnd, + onFinish: onFinish, ); @override diff --git a/dart/lib/src/protocol/sentry_span.dart b/dart/lib/src/protocol/sentry_span.dart index e204eabfd6..522287330e 100644 --- a/dart/lib/src/protocol/sentry_span.dart +++ b/dart/lib/src/protocol/sentry_span.dart @@ -7,6 +7,8 @@ import '../sentry_tracer.dart'; import '../tracing.dart'; import '../utils.dart'; +typedef OnFinishedCallback = Future Function({DateTime? endTimestamp}); + class SentrySpan extends ISentrySpan { final SentrySpanContext _context; DateTime? _endTimestamp; @@ -19,7 +21,7 @@ class SentrySpan extends ISentrySpan { SpanStatus? _status; final Map _tags = {}; - Function({DateTime? endTimestamp})? _finishedCallback; + OnFinishedCallback? _finishedCallback; @override final SentryTracesSamplingDecision? samplingDecision; @@ -30,7 +32,7 @@ class SentrySpan extends ISentrySpan { this._hub, { DateTime? startTimestamp, this.samplingDecision, - Function({DateTime? endTimestamp})? finishedCallback, + OnFinishedCallback? finishedCallback, }) { _startTimestamp = startTimestamp?.toUtc() ?? _hub.options.clock(); _finishedCallback = finishedCallback; diff --git a/dart/lib/src/scope.dart b/dart/lib/src/scope.dart index c4a9c68c2c..aca1ac7a14 100644 --- a/dart/lib/src/scope.dart +++ b/dart/lib/src/scope.dart @@ -9,6 +9,8 @@ import 'sentry_options.dart'; import 'sentry_span_interface.dart'; import 'sentry_tracer.dart'; +typedef _OnScopeObserver = Future Function(ScopeObserver observer); + /// Scope data to be sent with the event class Scope { /// How important this event is. @@ -445,8 +447,7 @@ class Scope { return clone; } - Future _callScopeObservers( - Future Function(ScopeObserver) action) async { + Future _callScopeObservers(_OnScopeObserver action) async { if (_options.enableScopeSync) { for (final scopeObserver in _options.scopeObservers) { await action(scopeObserver); diff --git a/dart/lib/src/sentry.dart b/dart/lib/src/sentry.dart index 84c9f1dfd2..3a26543218 100644 --- a/dart/lib/src/sentry.dart +++ b/dart/lib/src/sentry.dart @@ -61,10 +61,7 @@ class Sentry { await _init(sentryOptions, appRunner, callAppRunnerInRunZonedGuarded); } - static Future _initDefaultValues( - SentryOptions options, - AppRunner? appRunner, - ) async { + static Future _initDefaultValues(SentryOptions options) async { _setEnvironmentVariables(options); // Throws when running on the browser diff --git a/dart/lib/src/sentry_tracer.dart b/dart/lib/src/sentry_tracer.dart index 215e4fd11b..d78aee7041 100644 --- a/dart/lib/src/sentry_tracer.dart +++ b/dart/lib/src/sentry_tracer.dart @@ -23,7 +23,7 @@ class SentryTracer extends ISentrySpan { @visibleForTesting Timer? get autoFinishAfterTimer => _autoFinishAfterTimer; - Function(SentryTracer)? _onFinish; + OnTransactionFinish? _onFinish; var _finishStatus = SentryTracerFinishStatus.notFinishing(); late final bool _trimEnd; @@ -51,7 +51,7 @@ class SentryTracer extends ISentrySpan { bool waitForChildren = false, Duration? autoFinishAfter, bool trimEnd = false, - Function(SentryTracer)? onFinish, + OnTransactionFinish? onFinish, }) { _rootSpan = SentrySpan( this, diff --git a/dart/test/sentry_span_test.dart b/dart/test/sentry_span_test.dart index 03b057cf46..e1739e864f 100644 --- a/dart/test/sentry_span_test.dart +++ b/dart/test/sentry_span_test.dart @@ -226,7 +226,7 @@ void main() { test('callback called on finish', () async { var numberOfCallbackCalls = 0; - final sut = fixture.getSut(finishedCallback: ({DateTime? endTimestamp}) { + final sut = fixture.getSut(finishedCallback: ({DateTime? endTimestamp}) async { numberOfCallbackCalls += 1; }); @@ -269,7 +269,7 @@ class Fixture { SentrySpan getSut({ DateTime? startTimestamp, bool? sampled = true, - Function({DateTime? endTimestamp})? finishedCallback, + OnFinishedCallback? finishedCallback, Duration? autoFinishAfter, }) { tracer = SentryTracer(context, hub, autoFinishAfter: autoFinishAfter); diff --git a/flutter/lib/src/integrations/widgets_flutter_binding_integration.dart b/flutter/lib/src/integrations/widgets_flutter_binding_integration.dart index 5187f7cdea..26fff0cebd 100644 --- a/flutter/lib/src/integrations/widgets_flutter_binding_integration.dart +++ b/flutter/lib/src/integrations/widgets_flutter_binding_integration.dart @@ -4,16 +4,17 @@ import 'package:flutter/widgets.dart'; import 'package:sentry/sentry.dart'; import '../sentry_flutter_options.dart'; +typedef OnWidgetsBinding = WidgetsBinding Function(); + /// It is necessary to initialize Flutter method channels so that our plugin can /// call into the native code. class WidgetsFlutterBindingIntegration extends Integration { - WidgetsFlutterBindingIntegration( - [WidgetsBinding Function()? ensureInitialized]) + WidgetsFlutterBindingIntegration([OnWidgetsBinding? ensureInitialized]) : _ensureInitialized = ensureInitialized ?? WidgetsFlutterBinding.ensureInitialized; - final WidgetsBinding Function() _ensureInitialized; + final OnWidgetsBinding _ensureInitialized; @override FutureOr call(Hub hub, SentryFlutterOptions options) { From ff1e41905f3955197b329b9ac3a00bc8023bb603 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Wed, 7 Dec 2022 15:26:27 +0100 Subject: [PATCH 2/4] pr id --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fc5f362d8..4838781ef3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Fixes -- Missing slow and frozen frames for Auto transactions ([#1152](https://github.com/getsentry/sentry-dart/pull/1152)) +- Missing slow and frozen frames for Auto transactions ([#1172](https://github.com/getsentry/sentry-dart/pull/1172)) ### Dependencies From 50540e5c4ce8f9f516bf66ac36bbf6463ef12a76 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Wed, 7 Dec 2022 15:27:03 +0100 Subject: [PATCH 3/4] fix --- dart/lib/src/sentry.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dart/lib/src/sentry.dart b/dart/lib/src/sentry.dart index 3a26543218..ac7f20fce2 100644 --- a/dart/lib/src/sentry.dart +++ b/dart/lib/src/sentry.dart @@ -41,7 +41,7 @@ class Sentry { @internal SentryOptions? options, }) async { final sentryOptions = options ?? SentryOptions(); - await _initDefaultValues(sentryOptions, appRunner); + await _initDefaultValues(sentryOptions); try { await optionsConfiguration(sentryOptions); From f5551592e59e06c1413276d1ebaa20c5ffbaebd9 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Wed, 7 Dec 2022 15:31:37 +0100 Subject: [PATCH 4/4] fix --- dart/test/sentry_span_test.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dart/test/sentry_span_test.dart b/dart/test/sentry_span_test.dart index e1739e864f..c9820485fb 100644 --- a/dart/test/sentry_span_test.dart +++ b/dart/test/sentry_span_test.dart @@ -226,7 +226,8 @@ void main() { test('callback called on finish', () async { var numberOfCallbackCalls = 0; - final sut = fixture.getSut(finishedCallback: ({DateTime? endTimestamp}) async { + final sut = + fixture.getSut(finishedCallback: ({DateTime? endTimestamp}) async { numberOfCallbackCalls += 1; });