Skip to content

Commit d6a42b2

Browse files
committed
end_timestamp improvements
1 parent ba29f0c commit d6a42b2

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

sentry_sdk/traces.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,20 @@ def _end(self, end_timestamp: "Optional[Union[float, datetime]]" = None) -> None
315315

316316
# Set the end timestamp
317317
if end_timestamp is not None:
318-
try:
319-
if isinstance(end_timestamp, float):
318+
if isinstance(end_timestamp, (float, int)):
319+
try:
320320
end_timestamp = datetime.fromtimestamp(end_timestamp, timezone.utc)
321-
self._timestamp = end_timestamp
322-
except Exception:
323-
logger.debug(f"Failed to set end_timestamp: {end_timestamp}")
321+
except Exception:
322+
logger.debug(
323+
"Failed to set end_timestamp. Using current time instead."
324+
)
325+
326+
if isinstance(end_timestamp, datetime):
327+
self._timestamp = end_timestamp
328+
else:
329+
logger.debug(
330+
"Failed to set end_timestamp. Using current time instead."
331+
)
324332

325333
if self._timestamp is None:
326334
try:

0 commit comments

Comments
 (0)