Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion sentry_sdk/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
T = TypeVar("T")


PY37 = sys.version_info[0] == 3 and sys.version_info[1] >= 7
PY38 = sys.version_info[0] == 3 and sys.version_info[1] >= 8
PY310 = sys.version_info[0] == 3 and sys.version_info[1] >= 10
PY311 = sys.version_info[0] == 3 and sys.version_info[1] >= 11
Expand Down
6 changes: 3 additions & 3 deletions sentry_sdk/traces.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import copy
import sys
import time
import uuid
from datetime import datetime, timedelta, timezone
from enum import Enum
Expand All @@ -18,7 +19,6 @@
format_attribute,
get_current_thread_meta,
logger,
nanosecond_time,
should_be_treated_as_error,
)

Expand Down Expand Up @@ -239,7 +239,7 @@ def __init__(

# profiling depends on this value and requires that
# it is measured in nanoseconds
self._start_timestamp_monotonic_ns = nanosecond_time()
self._start_timestamp_monotonic_ns = time.perf_counter_ns()

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

Expand Down Expand Up @@ -352,7 +352,7 @@ def _end(self, end_timestamp: "Optional[Union[float, datetime]]" = None) -> None
)

if self._end_timestamp is None:
elapsed = nanosecond_time() - self._start_timestamp_monotonic_ns
elapsed = time.perf_counter_ns() - self._start_timestamp_monotonic_ns
self._end_timestamp = self._start_timestamp + timedelta(
microseconds=elapsed / 1000
)
Expand Down
12 changes: 0 additions & 12 deletions sentry_sdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
from typing import TYPE_CHECKING

import sentry_sdk
from sentry_sdk._compat import PY37
from sentry_sdk._types import SENSITIVE_DATA_SUBSTITUTE, Annotated, AnnotatedValue
from sentry_sdk.consts import (
DEFAULT_ADD_FULL_STACK,
Expand Down Expand Up @@ -1722,17 +1721,6 @@ def runner(*args: "P.args", **kwargs: "P.kwargs") -> "R":
return patcher


if PY37:

def nanosecond_time() -> int:
return time.perf_counter_ns()

else:

def nanosecond_time() -> int:
return int(time.perf_counter() * 1e9)


def now() -> float:
return time.perf_counter()

Expand Down
7 changes: 2 additions & 5 deletions tests/test_gevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest

import sentry_sdk
from sentry_sdk._compat import PY37, PY38
from sentry_sdk._compat import PY38

pytest.importorskip("gevent")

Expand Down Expand Up @@ -33,10 +33,7 @@ def inner(**kwargs):
@pytest.mark.parametrize("client_flush_method", ["close", "flush"])
@pytest.mark.parametrize("use_pickle", (True, False))
@pytest.mark.parametrize("compression_level", (0, 9, None))
@pytest.mark.parametrize(
"compression_algo",
(("gzip", "br", "<invalid>", None) if PY37 else ("gzip", "<invalid>", None)),
)
@pytest.mark.parametrize("compression_algo", ("gzip", "br", "<invalid>", None))
@pytest.mark.parametrize("http2", [True, False] if PY38 else [False])
def test_transport_works_gevent(
capturing_server,
Expand Down
16 changes: 2 additions & 14 deletions tests/test_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
capture_message,
isolation_scope,
)
from sentry_sdk._compat import PY37, PY38
from sentry_sdk._compat import PY38
from sentry_sdk.envelope import Envelope, Item, PayloadRef, parse_json
from sentry_sdk.integrations.asyncio import AsyncioIntegration
from sentry_sdk.integrations.logging import LoggingIntegration, ignore_logger_for_events
Expand Down Expand Up @@ -124,7 +124,7 @@ def inner(**kwargs):
(True, "close", False, 9, None, True),
(False, "flush", False, 9, None, False),
]
elif PY37:
else:
_transport_works_cases = [
(True, "close", True, None, "gzip", False),
(False, "flush", True, None, "br", False),
Expand All @@ -139,18 +139,6 @@ def inner(**kwargs):
(True, "close", False, 9, "<invalid>", False),
(False, "flush", False, 9, None, False),
]
else:
_transport_works_cases = [
(True, "close", True, None, "gzip", False),
(False, "flush", True, None, "<invalid>", False),
(True, "close", False, None, None, False),
(False, "flush", False, 0, "gzip", False),
(True, "close", True, 0, "<invalid>", False),
(False, "flush", True, 0, None, False),
(True, "close", False, 9, "gzip", False),
(False, "flush", False, 9, "<invalid>", False),
(True, "close", True, 9, None, False),
]


@pytest.mark.parametrize(
Expand Down
Loading