Skip to content

Commit

Permalink
sentry.init() can now be called more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Valsecchi committed Sep 11, 2017
1 parent d342afb commit 8a4d1a8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions c2cwsgiutils/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ def init(config=None):
global client
sentry_url = _utils.env_or_config(config, 'SENTRY_URL', 'c2c.sentry.url')
if sentry_url is not None:
client_info = {key[14:].lower(): value
for key, value in os.environ.items() if key.startswith('SENTRY_CLIENT_')}
git_hash = _utils.env_or_config(config, 'GIT_HASH', 'c2c.git_hash')
if git_hash is not None and not ('release' in client_info and client_info['release'] != 'latest'):
client_info['release'] = git_hash
client_info['tags'] = {key[11:].lower(): value
for key, value in os.environ.items() if key.startswith('SENTRY_TAG_')}
client_info['ignore_exceptions'] = client_info.get('ignore_exceptions', 'SystemExit').split(",")
client = Client(sentry_url, **client_info)
if client is None:
client_info = {key[14:].lower(): value
for key, value in os.environ.items() if key.startswith('SENTRY_CLIENT_')}
git_hash = _utils.env_or_config(config, 'GIT_HASH', 'c2c.git_hash')
if git_hash is not None and not ('release' in client_info and client_info['release'] != 'latest'):
client_info['release'] = git_hash
client_info['tags'] = {key[11:].lower(): value
for key, value in os.environ.items() if key.startswith('SENTRY_TAG_')}
client_info['ignore_exceptions'] = client_info.get('ignore_exceptions', 'SystemExit').split(",")
client = Client(sentry_url, **client_info)
handler = SentryHandler(client=client)
handler.setLevel(_utils.env_or_config(config, 'SENTRY_LEVEL', 'c2c.sentry_level', 'ERROR').upper())

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from setuptools import setup, find_packages


VERSION = '0.23.0'
VERSION = '0.24.0'
HERE = os.path.abspath(os.path.dirname(__file__))
INSTALL_REQUIRES = open(os.path.join(HERE, 'requirements.txt')).read().splitlines()

Expand Down

0 comments on commit 8a4d1a8

Please sign in to comment.