Skip to content

Commit

Permalink
fix: use options.clock as endtimestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind committed Nov 7, 2022
1 parent 76410c3 commit f241249
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
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

- Use `Options.clock` where possible instead of current UTC DateTime ([#1110](https://github.com/getsentry/sentry-dart/pull/1110))

### Dependencies

- Bump Android SDK from v6.6.0 to v6.7.0 ([#1105](https://github.com/getsentry/sentry-dart/pull/1105))
Expand Down
10 changes: 5 additions & 5 deletions dart/lib/src/protocol/sentry_span.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ class SentrySpan extends ISentrySpan {
return;
}

final utcDateTime = getUtcDateTime();

if (status != null) {
_status = status;
}

if (endTimestamp?.isBefore(_startTimestamp) ?? false) {
if (endTimestamp == null) {
_endTimestamp = _hub.options.clock();
} else if (endTimestamp.isBefore(_startTimestamp)) {
_hub.options.logger(
SentryLevel.warning,
'End timestamp ($endTimestamp) cannot be before start timestamp ($_startTimestamp)',
);
_endTimestamp = utcDateTime;
_endTimestamp = _hub.options.clock();
} else {
_endTimestamp = endTimestamp?.toUtc() ?? utcDateTime;
_endTimestamp = endTimestamp.toUtc();
}

// associate error
Expand Down
2 changes: 1 addition & 1 deletion dart/lib/src/sentry_tracer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class SentryTracer extends ISentrySpan {

@override
Future<void> finish({SpanStatus? status, DateTime? endTimestamp}) async {
final commonEndTimestamp = endTimestamp ?? getUtcDateTime();
final commonEndTimestamp = endTimestamp ?? _hub.options.clock();
_autoFinishAfterTimer?.cancel();
_finishStatus = SentryTracerFinishStatus.finishing(status);
if (!_rootSpan.finished &&
Expand Down

0 comments on commit f241249

Please sign in to comment.