-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
sentry_runner(feat): Report development issues #24512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
61a706e
99d8b44
1757b5a
6d7fafb
52d3295
e72a612
5919cc7
5ae0ca8
c61c05f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,7 +43,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" --level $log_level | ||
| SENTRY_DSN=${SENTRY_DEVENV_DSN} \ | ||
| sentry-cli send-event -m "$error_message" --logfile "$_SENTRY_LOG_FILE" --level $log_level | ||
| rm "$_SENTRY_LOG_FILE" | ||
| } | ||
|
|
||
|
|
@@ -125,12 +126,19 @@ export NODE_OPTIONS=--max-old-space-size=4096 | |
| # Enable this by default for development envs (CI/deploys do not use envrc) | ||
| export SENTRY_UI_HOT_RELOAD=1 | ||
|
|
||
| ### You can override the exported variables with a .env file | ||
| # All exports should happen before here unless they're safeguarded (see devenv error reporting below) | ||
| if [ -f '.env' ]; then | ||
| info ".env found. Reading it..." | ||
| dotenv .env | ||
| fi | ||
|
|
||
| ## Notify of reporting to Sentry | ||
| if [ -n "${SENTRY_DEVENV_NO_REPORT+x}" ]; 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."$'\n'" 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 | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm renaming this variable since |
||
| fi | ||
|
|
||
| ### System ### | ||
|
|
@@ -217,11 +225,6 @@ PATH_add node_modules/.bin | |
|
|
||
| ### Overrides ### | ||
|
|
||
| if [ -f '.env' ]; then | ||
| info ".env found. Reading it..." | ||
| dotenv .env | ||
| fi | ||
|
|
||
| cat <<EOF | ||
| ${green}${bold}direnv: SUCCESS! | ||
| ${reset} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,10 @@ | ||
| import logging | ||
| import os | ||
| import click | ||
| import sys | ||
| import sentry | ||
| import datetime | ||
| import sentry_sdk | ||
| from sentry.utils.imports import import_string | ||
| from sentry.utils.compat import map | ||
|
|
||
|
|
@@ -161,4 +163,31 @@ def call_command(name, obj=None, **kwargs): | |
|
|
||
|
|
||
| def main(): | ||
| cli(prog_name=get_prog(), obj={}, max_content_width=100) | ||
| func = cli | ||
| kwargs = { | ||
| "prog_name": get_prog(), | ||
| "obj": {}, | ||
| "max_content_width": 100, | ||
| } | ||
| # This variable is *only* set as part of direnv/.envrc, thus, we cannot affect production | ||
| if os.environ.get("SENTRY_DEVENV_DSN"): | ||
| # We do this here because `configure_structlog` executes later | ||
| logging.basicConfig(format="%(levelname)s:%(message)s", level=logging.INFO) | ||
| logger = logging.getLogger(__name__) | ||
|
|
||
| logger.info( | ||
| "The Sentry runner will report development issues to Sentry.io. " | ||
| "Use SENTRY_DEVENV_NO_REPORT to avoid reporting issues." | ||
| ) | ||
| try: | ||
| func(**kwargs) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| except Exception as e: | ||
| # This reports to the project sentry-dev-env | ||
| with sentry_sdk.init(dsn=os.environ["SENTRY_DEVENV_DSN"]): | ||
armenzg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if os.environ.get("USER"): | ||
| sentry_sdk.set_user({"username": os.environ.get("USER")}) | ||
| sentry_sdk.capture_exception(e) | ||
| logger.info("We have reported the error below to Sentry") | ||
| raise e | ||
| else: | ||
| func(**kwargs) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving this up here works better when I want to load "SENTRY_DEVENV_NO_REPORT" through the
.envfile.