Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Addressed import issues and utcfromtimestamp deprecation handled as well
  • Loading branch information
rmad17 committed Oct 6, 2023
commit 44799c907c5c4bb92e3b699de74d9289120b9968
9 changes: 8 additions & 1 deletion sentry_sdk/_compat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
import contextlib
from datetime import datetime, timezone
from datetime import datetime
from functools import wraps

from sentry_sdk._types import TYPE_CHECKING
Expand Down Expand Up @@ -36,6 +36,9 @@
def datetime_utcnow():
return datetime.utcnow()

def utc_from_timestamp(timestamp):
return datetime.utcfromtimestamp(timestamp)

def implements_str(cls):
# type: (T) -> T
cls.__unicode__ = cls.__str__
Expand Down Expand Up @@ -82,6 +85,7 @@ def when_called(*args, **kwargs):
return DecoratorContextManager

else:
from datetime import timezone
import urllib.parse as urlparse # noqa

text_type = str
Expand All @@ -94,6 +98,9 @@ def when_called(*args, **kwargs):
def datetime_utcnow():
return datetime.now(timezone.utc)

def utc_from_timestamp(timestamp):
return datetime.fromtimestamp(timestamp, timezone.utc)

def implements_str(x):
# type: (T) -> T
return x
Expand Down
5 changes: 2 additions & 3 deletions sentry_sdk/integrations/logging.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import absolute_import

import logging
import datetime
from fnmatch import fnmatch

from sentry_sdk.hub import Hub
Expand All @@ -12,7 +11,7 @@
capture_internal_exceptions,
)
from sentry_sdk.integrations import Integration
from sentry_sdk._compat import iteritems
from sentry_sdk._compat import iteritems, utc_from_timestamp

from sentry_sdk._types import TYPE_CHECKING

Expand Down Expand Up @@ -282,6 +281,6 @@ def _breadcrumb_from_record(self, record):
"level": self._logging_to_event_level(record),
"category": record.name,
"message": record.message,
"timestamp": datetime.datetime.utcfromtimestamp(record.created),
"timestamp": utc_from_timestamp(record.created),
"data": self._extra_from_record(record),
}