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
move finishAfter implementation out of abstract class
  • Loading branch information
Denis Andraลกec authored and Denis Andraลกec committed Dec 1, 2021
commit 6161cb05b83a61f4b000346f1bc9950927f5ea88
11 changes: 11 additions & 0 deletions dart/lib/src/protocol/sentry_span.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:async';

import '../hub.dart';
import '../protocol.dart';

Expand All @@ -17,6 +19,7 @@ class SentrySpan extends ISentrySpan {

SpanStatus? _status;
final Map<String, String> _tags = {};
Timer? _finishAfterTimer;

@override
bool? sampled;
Expand All @@ -32,6 +35,7 @@ class SentrySpan extends ISentrySpan {

@override
Future<void> finish({SpanStatus? status}) async {
_finishAfterTimer?.cancel();
if (status != null) {
_status = status;
}
Expand All @@ -45,6 +49,13 @@ class SentrySpan extends ISentrySpan {
await super.finish(status: status);
}

@override
void finishAfter(Duration duration, {SpanStatus? status}) {
_finishAfterTimer = Timer(duration, () async {
await finish(status: status);
});
}

@override
void removeData(String key) {
_data.remove(key);
Expand Down
11 changes: 6 additions & 5 deletions dart/lib/src/sentry_tracer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SentryTracer extends ISentrySpan {
late final SentrySpan _rootSpan;
final List<SentrySpan> _children = [];
final Map<String, String> _extra = {};
Timer? _idleTimer;
Timer? _finishAfterTimer;
var _finishStatus = SentryTracerFinishStatus.notFinishing();

SentryTracer(SentryTransactionContext transactionContext, this._hub,
Expand All @@ -30,11 +30,12 @@ class SentryTracer extends ISentrySpan {

@override
Future<void> finish({SpanStatus? status}) async {
_idleTimer?.cancel();
_finishAfterTimer?.cancel();
_finishStatus = SentryTracerFinishStatus.finishing(status);
if (!_rootSpan.finished &&
(!_waitForChildren || _haveAllChildrenFinished())) {
await _rootSpan.finish(status: status);
_rootSpan.status ??= status;
await _rootSpan.finish();

// finish unfinished spans otherwise transaction gets dropped
for (final span in _children) {
Expand All @@ -59,8 +60,8 @@ class SentryTracer extends ISentrySpan {

@override
void finishAfter(Duration duration, {SpanStatus? status}) {
_idleTimer = Timer(duration, () async {
await finish(status: _rootSpan.status ?? status);
_finishAfterTimer = Timer(duration, () async {
await finish(status: status);
});
}

Expand Down
10 changes: 10 additions & 0 deletions dart/test/sentry_span_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ void main() {
expect(sut.toSentryTrace().value,
'${sut.context.traceId}-${sut.context.spanId}-1');
});

test('finishes after duration', () async {
final sut = fixture.getSut();
sut.finishAfter(Duration(milliseconds: 200), status: SpanStatus.ok());

expect(sut.finished, false);
await Future.delayed(Duration(milliseconds: 210));
expect(sut.status, SpanStatus.ok());
expect(sut.finished, true);
});
}

class Fixture {
Expand Down
2 changes: 1 addition & 1 deletion dart/test/sentry_tracer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void main() {
'${sut.context.traceId}-${sut.context.spanId}-1');
});

test('tracer finishes after idle time', () async {
test('tracer finishes after duration', () async {
final sut = fixture.getSut();
sut.finishAfter(Duration(milliseconds: 200), status: SpanStatus.ok());

Expand Down