Skip to content

Missing slow and frozen frames for Auto transactions #1172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 9, 2022
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Fixes

- Missing slow and frozen frames for Auto transactions ([#1172](https://github.com/getsentry/sentry-dart/pull/1172))

### Dependencies

- Bump Android SDK from v6.9.1 to v6.9.2 ([#1167](https://github.com/getsentry/sentry-dart/pull/1167))
Expand Down
1 change: 1 addition & 0 deletions dart/lib/src/hub_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class HubAdapter implements Hub {
waitForChildren: waitForChildren,
autoFinishAfter: autoFinishAfter,
trimEnd: trimEnd,
onFinish: onFinish,
);

@override
Expand Down
6 changes: 4 additions & 2 deletions dart/lib/src/protocol/sentry_span.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import '../sentry_tracer.dart';
import '../tracing.dart';
import '../utils.dart';

typedef OnFinishedCallback = Future<void> Function({DateTime? endTimestamp});

class SentrySpan extends ISentrySpan {
final SentrySpanContext _context;
DateTime? _endTimestamp;
Expand All @@ -19,7 +21,7 @@ class SentrySpan extends ISentrySpan {

SpanStatus? _status;
final Map<String, String> _tags = {};
Function({DateTime? endTimestamp})? _finishedCallback;
OnFinishedCallback? _finishedCallback;

@override
final SentryTracesSamplingDecision? samplingDecision;
Expand All @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions dart/lib/src/scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import 'sentry_options.dart';
import 'sentry_span_interface.dart';
import 'sentry_tracer.dart';

typedef _OnScopeObserver = Future<void> Function(ScopeObserver observer);

/// Scope data to be sent with the event
class Scope {
/// How important this event is.
Expand Down Expand Up @@ -445,8 +447,7 @@ class Scope {
return clone;
}

Future<void> _callScopeObservers(
Future<void> Function(ScopeObserver) action) async {
Future<void> _callScopeObservers(_OnScopeObserver action) async {
if (_options.enableScopeSync) {
for (final scopeObserver in _options.scopeObservers) {
await action(scopeObserver);
Expand Down
7 changes: 2 additions & 5 deletions dart/lib/src/sentry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -61,10 +61,7 @@ class Sentry {
await _init(sentryOptions, appRunner, callAppRunnerInRunZonedGuarded);
}

static Future<void> _initDefaultValues(
SentryOptions options,
AppRunner? appRunner,
) async {
static Future<void> _initDefaultValues(SentryOptions options) async {
_setEnvironmentVariables(options);

// Throws when running on the browser
Expand Down
4 changes: 2 additions & 2 deletions dart/lib/src/sentry_tracer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -51,7 +51,7 @@ class SentryTracer extends ISentrySpan {
bool waitForChildren = false,
Duration? autoFinishAfter,
bool trimEnd = false,
Function(SentryTracer)? onFinish,
OnTransactionFinish? onFinish,
}) {
_rootSpan = SentrySpan(
this,
Expand Down
5 changes: 3 additions & 2 deletions dart/test/sentry_span_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ 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;
});

Expand Down Expand Up @@ -269,7 +270,7 @@ class Fixture {
SentrySpan getSut({
DateTime? startTimestamp,
bool? sampled = true,
Function({DateTime? endTimestamp})? finishedCallback,
OnFinishedCallback? finishedCallback,
Duration? autoFinishAfter,
}) {
tracer = SentryTracer(context, hub, autoFinishAfter: autoFinishAfter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<SentryFlutterOptions> {
WidgetsFlutterBindingIntegration(
[WidgetsBinding Function()? ensureInitialized])
WidgetsFlutterBindingIntegration([OnWidgetsBinding? ensureInitialized])
: _ensureInitialized =
ensureInitialized ?? WidgetsFlutterBinding.ensureInitialized;

final WidgetsBinding Function() _ensureInitialized;
final OnWidgetsBinding _ensureInitialized;

@override
FutureOr<void> call(Hub hub, SentryFlutterOptions options) {
Expand Down