-
-
Notifications
You must be signed in to change notification settings - Fork 775
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
Sentry integration #1846
Merged
Sentry integration #1846
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f1997ff
Sentry integration - deprecate rollbar
mbeacom 714888a
Imports are hard
mbeacom 0d2e741
dbl quotez
mbeacom a14ffdb
Single quotes
mbeacom 8c450a9
Fix travis
mbeacom 5e9ffcf
Forgot to save this file xD
mbeacom cbe197d
Merge branch 'master' into sentry
mbeacom ef61f6d
Add middleware and wsgi handler
mbeacom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,13 +17,14 @@ | |
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
""" | ||
import os | ||
import socket | ||
|
||
from django.http import Http404 | ||
from django.utils.translation import gettext_noop | ||
|
||
import environ | ||
import rollbar | ||
import raven | ||
from easy_thumbnails.conf import Settings as easy_thumbnails_defaults | ||
|
||
root = environ.Path(__file__) - 2 # Set the base directory to two levels. | ||
|
@@ -70,6 +71,7 @@ | |
'autotranslate', | ||
'django_extensions', | ||
'easy_thumbnails', | ||
'raven.contrib.django.raven_compat', | ||
'app', | ||
'avatar', | ||
'retail', | ||
|
@@ -189,26 +191,46 @@ | |
if ENV not in ['local', 'test']: | ||
LOGGING = { | ||
'version': 1, | ||
'disable_existing_loggers': False, | ||
'filters': { | ||
'require_debug_is_false': { | ||
'()': 'django.utils.log.RequireDebugFalse' | ||
'disable_existing_loggers': True, | ||
'root': { | ||
'level': 'WARNING', | ||
'handlers': ['sentry'], | ||
}, | ||
'formatters': { | ||
'verbose': { | ||
'format': '%(levelname)s %(asctime)s %(module)s ' | ||
'%(process)d %(thread)d %(message)s' | ||
}, | ||
}, | ||
'handlers': { | ||
'rotatingfilehandler': { | ||
'level': 'DEBUG', | ||
'class': 'logging.handlers.RotatingFileHandler', | ||
'filename': '/var/log/django/debug.log', | ||
'maxBytes': 1024 * 1024 * 10, # 10 MB | ||
'backupCount': 100, # max 100 logs | ||
'sentry': { | ||
'level': 'ERROR', # To capture more than ERROR, change to WARNING, INFO, etc. | ||
'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler', | ||
'tags': { | ||
'custom-tag': 'x' | ||
}, | ||
}, | ||
'console': { | ||
'level': 'DEBUG', | ||
'class': 'logging.StreamHandler', | ||
'formatter': 'verbose' | ||
} | ||
}, | ||
'loggers': { | ||
'django': { | ||
'handlers': ['rotatingfilehandler', ], | ||
'propagate': True, | ||
'filters': ['require_debug_is_false'], | ||
'django.db.backends': { | ||
'level': 'ERROR', | ||
'handlers': ['console'], | ||
'propagate': False, | ||
}, | ||
'raven': { | ||
'level': 'DEBUG', | ||
'handlers': ['console'], | ||
'propagate': False, | ||
}, | ||
'sentry.errors': { | ||
'level': 'DEBUG', | ||
'handlers': ['console'], | ||
'propagate': False, | ||
}, | ||
}, | ||
} | ||
|
@@ -370,38 +392,19 @@ | |
} | ||
HOTJAR_CONFIG = {'hjid': env.int('HOTJAR_ID', default=0), 'hjsv': env.int('HOTJAR_SV', default=0), } | ||
|
||
# Rollbar - https://rollbar.com/docs/notifier/pyrollbar/#django | ||
ROLLBAR_CLIENT_TOKEN = env('ROLLBAR_CLIENT_TOKEN', default='') # post_client_item | ||
ROLLBAR_SERVER_TOKEN = env('ROLLBAR_SERVER_TOKEN', default='') # post_server_item | ||
if ROLLBAR_SERVER_TOKEN and ENV not in ['local', 'test']: | ||
# Handle rollbar initialization. | ||
ROLLBAR = { | ||
'access_token': ROLLBAR_SERVER_TOKEN, | ||
'environment': ENV, | ||
'root': BASE_DIR, | ||
'patch_debugview': False, # Disable debug view patching. | ||
'branch': 'master', | ||
'exception_level_filters': [(Http404, 'ignored')], | ||
'capture_ip': 'anonymize', | ||
'capture_username': True, | ||
'scrub_fields': [ | ||
'pw', 'passwd', 'password', 'secret', 'confirm_password', 'confirmPassword', 'password_confirmation', | ||
'passwordConfirmation', 'access_token', 'accessToken', 'auth', 'authentication', 'github_access_token', | ||
'github_client_secret', 'secret_key', 'twitter_access_token', 'twitter_access_secret', | ||
'twitter_consumer_secret', 'mixpanel_token', 'slack_verification_token', 'redirect_state', 'slack_token', | ||
'priv_key', | ||
], | ||
# Sentry | ||
SENTRY_USER = env('SENTRY_USER', default='') | ||
SENTRY_PASSWORD = env('SENTRY_PASSWORD', default='') | ||
SENTRY_ADDRESS = env('SENTRY_ADDRESS', default='') | ||
SENTRY_PROJECT = env('SENTRY_PROJECT', default='') | ||
SENTRY_RELEASE = raven.fetch_git_sha(os.path.abspath(os.pardir)) if SENTRY_USER else '' | ||
if SENTRY_ADDRESS and SENTRY_PROJECT: | ||
RAVEN_CONFIG = { | ||
'dsn': f'https://{SENTRY_USER}:{SENTRY_PASSWORD}@{SENTRY_ADDRESS}/{SENTRY_PROJECT}', | ||
# If you are using git, you can also automatically configure the | ||
# release based on the git info. | ||
'release': SENTRY_RELEASE, | ||
} | ||
MIDDLEWARE.append('rollbar.contrib.django.middleware.RollbarNotifierMiddleware') | ||
REST_FRAMEWORK['EXCEPTION_HANDLER'] = 'rollbar.contrib.django_rest_framework.post_exception_handler' | ||
# LOGGING['handlers']['rollbar'] = { | ||
# 'filters': ['require_debug_false'], | ||
# 'access_token': ROLLBAR_SERVER_TOKEN, | ||
# 'environment': ENV, | ||
# 'class': 'rollbar.logger.RollbarHandler', | ||
# } | ||
# LOGGING['loggers']['django']['handlers'].append('rollbar') | ||
rollbar.init(**ROLLBAR) | ||
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. 🔥 |
||
|
||
# List of github usernames to not count as comments on an issue | ||
IGNORE_COMMENTS_FROM = ['gitcoinbot', ] | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{% comment %} | ||
Copyright (C) 2018 Gitcoin Core | ||
|
||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published | ||
by the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
|
||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
{% endcomment %} | ||
{% if sentry_address %} | ||
{% load raven %} | ||
<script> | ||
Raven.config("{% sentry_public_dsn 'https' %}").install() | ||
</script> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hardcode
{SENTRY_ADDRESS}
->sentry.io
?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.
We aren't using the hosted solution. This gives whoever is running the app the choice of URI. We're self-hosting, since it's a fairly small footprint and we can retain data as long as necessary.