Skip to content

Replace deprecated datetime functions #2502

New issue

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

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

Already on GitHub? # to your account

Merged
merged 1 commit into from
Nov 13, 2023
Merged
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
8 changes: 4 additions & 4 deletions sentry_sdk/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import sentry_sdk
from sentry_sdk.consts import INSTRUMENTER
from sentry_sdk.utils import is_valid_sample_rate, logger, nanosecond_time
from sentry_sdk._compat import datetime_utcnow, PY2
from sentry_sdk._compat import datetime_utcnow, utc_from_timestamp, PY2
from sentry_sdk.consts import SPANDATA
from sentry_sdk._types import TYPE_CHECKING

Expand Down Expand Up @@ -147,9 +147,9 @@ def __init__(
self._data = {} # type: Dict[str, Any]
self._containing_transaction = containing_transaction
if start_timestamp is None:
start_timestamp = datetime.utcnow()
start_timestamp = datetime_utcnow()
elif isinstance(start_timestamp, float):
start_timestamp = datetime.utcfromtimestamp(start_timestamp)
start_timestamp = utc_from_timestamp(start_timestamp)
self.start_timestamp = start_timestamp
try:
# profiling depends on this value and requires that
Expand Down Expand Up @@ -468,7 +468,7 @@ def finish(self, hub=None, end_timestamp=None):
try:
if end_timestamp:
if isinstance(end_timestamp, float):
end_timestamp = datetime.utcfromtimestamp(end_timestamp)
end_timestamp = utc_from_timestamp(end_timestamp)
self.timestamp = end_timestamp
else:
elapsed = nanosecond_time() - self._start_timestamp_monotonic_ns
Expand Down