Skip to content

Commit 6815bc6

Browse files
committed
Fix initialization issue raised by cursor
1 parent 019fa47 commit 6815bc6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sentry_sdk/traces.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def __init__(
283283
# it is measured in nanoseconds
284284
self._start_timestamp_monotonic_ns = nanosecond_time()
285285
except AttributeError:
286-
pass
286+
self._start_timestamp_monotonic_ns = None
287287

288288
self._span_id: "Optional[str]" = None
289289

@@ -385,12 +385,12 @@ def _end(self, end_timestamp: "Optional[Union[float, datetime]]" = None) -> None
385385
)
386386

387387
if self._timestamp is None:
388-
try:
388+
if self._start_timestamp_monotonic_ns is not None:
389389
elapsed = nanosecond_time() - self._start_timestamp_monotonic_ns
390390
self._timestamp = self._start_timestamp + timedelta(
391391
microseconds=elapsed / 1000
392392
)
393-
except AttributeError:
393+
else:
394394
self._timestamp = datetime.now(timezone.utc)
395395

396396
client = sentry_sdk.get_client()

0 commit comments

Comments
 (0)