Skip to content

Commit

Permalink
Add option to set a Sentry environment. (#1395)
Browse files Browse the repository at this point in the history
* Add option to set a Sentry environment.
  • Loading branch information
smarnach authored Jun 21, 2022
1 parent 914cee5 commit c42c04b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ A collection of scripts related to the Remote Settings service.

## Sentry

All commands use Sentry to report any unexpected errors. The `SENTRY_DSN`
environment variable is not required but is recommended.
All commands use Sentry to report any unexpected errors. Sentry can be configured with these environment variables, which are recommended, but not required:

- `SENTRY_DSN`: The DSN from the "Client Keys" section in the project settings in Sentry.
- `SENTRY_ENV`: The environment to use for Sentry, e.g. dev, stage or prod.

## Commands

Expand Down
6 changes: 5 additions & 1 deletion aws_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@
from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration

SENTRY_DSN = config("SENTRY_DSN", default=None)
SENTRY_ENV = config("SENTRY_ENV", default=None)

if SENTRY_DSN:
# Note! If you don't do `sentry_sdk.init(DSN)` it will still work
# to do things like calling `sentry_sdk.capture_exception(exception)`
# It just means it's a noop.
sentry_sdk.init(SENTRY_DSN, integrations=[AwsLambdaIntegration()])
env_option = {}
if SENTRY_ENV:
env_option = {"environment": SENTRY_ENV}
sentry_sdk.init(SENTRY_DSN, integrations=[AwsLambdaIntegration()], **env_option)


def help_(**kwargs):
Expand Down

0 comments on commit c42c04b

Please sign in to comment.