Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
antonpirker committed Jun 21, 2023
1 parent 3fe8b83 commit 23dbfe4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
4 changes: 3 additions & 1 deletion sentry_sdk/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from sentry_sdk._types import TYPE_CHECKING

from sentry_sdk.consts import FALSE_VALUES

if TYPE_CHECKING:
from typing import Optional
from typing import Tuple
Expand Down Expand Up @@ -82,7 +84,7 @@ def check_thread_support():
if "threads" in opt:
return

if str(opt.get("enable-threads", "0")).lower() in ("false", "off", "no", "0"):
if str(opt.get("enable-threads", "0")).lower() in FALSE_VALUES:
from warnings import warn

warn(
Expand Down
8 changes: 8 additions & 0 deletions sentry_sdk/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@

MATCH_ALL = r".*"

FALSE_VALUES = [
"false",
"no",
"off",
"n",
"0",
]


class INSTRUMENTER:
SENTRY = "sentry"
Expand Down
12 changes: 3 additions & 9 deletions sentry_sdk/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
from sentry_sdk._types import TYPE_CHECKING
from sentry_sdk.utils import logger, capture_internal_exceptions

from sentry_sdk.consts import FALSE_VALUES


if TYPE_CHECKING:
from typing import Any
Expand Down Expand Up @@ -135,18 +137,10 @@ def _load_trace_data_from_env(self):
"""
incoming_trace_information = None

false_values = [
"false",
"no",
"off",
"n",
"0",
]

sentry_use_environment = (
os.environ.get("SENTRY_USE_ENVIRONMENT") or ""
).lower()
use_environment = sentry_use_environment not in false_values
use_environment = sentry_use_environment not in FALSE_VALUES
if use_environment:
incoming_trace_information = {}

Expand Down

0 comments on commit 23dbfe4

Please sign in to comment.