Skip to content
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

Replace deprecated datetime functions #2502

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 @@
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)

Check warning on line 152 in sentry_sdk/tracing.py

View check run for this annotation

Codecov / codecov/patch

sentry_sdk/tracing.py#L152

Added line #L152 was not covered by tests
self.start_timestamp = start_timestamp
try:
# profiling depends on this value and requires that
Expand Down Expand Up @@ -468,7 +468,7 @@
try:
if end_timestamp:
if isinstance(end_timestamp, float):
end_timestamp = datetime.utcfromtimestamp(end_timestamp)
end_timestamp = utc_from_timestamp(end_timestamp)

Check warning on line 471 in sentry_sdk/tracing.py

View check run for this annotation

Codecov / codecov/patch

sentry_sdk/tracing.py#L471

Added line #L471 was not covered by tests
self.timestamp = end_timestamp
else:
elapsed = nanosecond_time() - self._start_timestamp_monotonic_ns
Expand Down
Loading