Skip to content
Closed
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
5 changes: 3 additions & 2 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ report_to_sentry() {
if ! require sentry-cli; then
curl -sL https://sentry.io/get-cli/ | bash
fi
sentry-cli send-event -m "$error_message" --logfile "$_SENTRY_LOG_FILE"
SENTRY_DSN=${SENTRY_DEVENV_DSN} \
sentry-cli send-event -m "$error_message" --logfile "$_SENTRY_LOG_FILE"
rm "$_SENTRY_LOG_FILE"
}

Expand Down Expand Up @@ -121,7 +122,7 @@ if [ "$SENTRY_DEVENV_NO_REPORT" ]; then
info "No development environment errors will be reported (since you've defined SENTRY_DEVENV_NO_REPORT)."
else
info "Development errors will be reported to Sentry.io. If you wish to opt-out, set SENTRY_DEVENV_NO_REPORT as an env variable."
export SENTRY_DSN=https://[email protected]/1492057
export SENTRY_DEVENV_DSN=https://[email protected]/1492057
fi

### System ###
Expand Down
11 changes: 11 additions & 0 deletions src/sentry/runner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,20 @@
import sys
import sentry
import datetime
import sentry_sdk
from sentry.utils.imports import import_string
from sentry.utils.compat import map

# SENTRY_DEVENV_DSN gets set up automatically by direnv/.envrc
# This check prevents executing this code unintentionally (e.g. CI or production)
if os.environ.get("SENTRY_DEVENV_DSN") and not os.environ.get("SENTRY_DEVENV_NO_REPORT"):
# This reports to the project sentry-dev-env
sentry_sdk.init(
dsn=os.environ["SENTRY_DEVENV_DSN"],
)
if os.environ.get("USER"):
sentry_sdk.set_user({"username": os.environ.get("USER")})

# We need to run this here because of a concurrency bug in Python's locale
# with the lazy initialization.
datetime.datetime.strptime("", "")
Expand Down
2 changes: 0 additions & 2 deletions src/sentry/utils/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@ def configure_sdk():
from sentry_sdk.integrations.celery import CeleryIntegration
from sentry_sdk.integrations.redis import RedisIntegration

assert sentry_sdk.Hub.main.client is None

sdk_options = dict(settings.SENTRY_SDK_CONFIG)

relay_dsn = sdk_options.pop("relay_dsn", None)
Expand Down