forked from CGM_Public/pretix_original
Built-in support for sentry
This commit is contained in:
@@ -16,7 +16,9 @@ the files found before.
|
|||||||
|
|
||||||
The file is expected to be in the INI format as specified in the `Python documentation`_.
|
The file is expected to be in the INI format as specified in the `Python documentation`_.
|
||||||
|
|
||||||
The config file may contain the following sections (all settings are optional and have default values).
|
The config file may contain the following sections (all settings are optional and have
|
||||||
|
default values). We suggest that you start from the examples given in one of the
|
||||||
|
installation tutorials.
|
||||||
|
|
||||||
pretix settings
|
pretix settings
|
||||||
---------------
|
---------------
|
||||||
@@ -205,7 +207,6 @@ If no memcached is configured, pretix will use Django's built-in local-memory ca
|
|||||||
shared memcached instance, not multiple ones, because cache invalidations would not be
|
shared memcached instance, not multiple ones, because cache invalidations would not be
|
||||||
propagated otherwise.
|
propagated otherwise.
|
||||||
|
|
||||||
|
|
||||||
Redis
|
Redis
|
||||||
-----
|
-----
|
||||||
|
|
||||||
@@ -242,6 +243,19 @@ RabbitMQ might be the better choice if you have a complex, multi-server, high-pe
|
|||||||
but as you already should have a redis instance ready for session and lock storage, we recommend
|
but as you already should have a redis instance ready for session and lock storage, we recommend
|
||||||
redis for convenience. See the `Celery documentation`_ for more details.
|
redis for convenience. See the `Celery documentation`_ for more details.
|
||||||
|
|
||||||
|
Sentry
|
||||||
|
------
|
||||||
|
|
||||||
|
pretix has native support for sentry, a tool that you can use to track errors in the
|
||||||
|
application. If you want to use sentry, you need to set a DSN in the configuration file.
|
||||||
|
|
||||||
|
[sentry]
|
||||||
|
dsn=https://<key>:<secret>@sentry.io/<project>
|
||||||
|
|
||||||
|
``dsn``
|
||||||
|
You will be given this value by your sentry installation.
|
||||||
|
|
||||||
|
|
||||||
Secret length
|
Secret length
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ def _add_items_to_cart(event: Event, items: List[dict], cart_id: str=None) -> No
|
|||||||
raise CartError(err)
|
raise CartError(err)
|
||||||
|
|
||||||
|
|
||||||
@app.task(base=ProfiledTask, bind=True, max_retries=5, default_retry_delay=1)
|
@app.task(base=ProfiledTask, bind=True, max_retries=5, default_retry_delay=1, throws=(CartError,))
|
||||||
def add_items_to_cart(self, event: int, items: List[dict], cart_id: str=None) -> None:
|
def add_items_to_cart(self, event: int, items: List[dict], cart_id: str=None) -> None:
|
||||||
"""
|
"""
|
||||||
Adds a list of items to a user's cart.
|
Adds a list of items to a user's cart.
|
||||||
@@ -259,7 +259,7 @@ def _remove_items_from_cart(event: Event, items: List[dict], cart_id: str) -> No
|
|||||||
cp.delete()
|
cp.delete()
|
||||||
|
|
||||||
|
|
||||||
@app.task(base=ProfiledTask, bind=True, max_retries=5, default_retry_delay=1)
|
@app.task(base=ProfiledTask, bind=True, max_retries=5, default_retry_delay=1, throws=(CartError,))
|
||||||
def remove_items_from_cart(self, event: int, items: List[dict], cart_id: str=None) -> None:
|
def remove_items_from_cart(self, event: int, items: List[dict], cart_id: str=None) -> None:
|
||||||
"""
|
"""
|
||||||
Removes a list of items from a user's cart.
|
Removes a list of items from a user's cart.
|
||||||
|
|||||||
@@ -602,7 +602,7 @@ class OrderChangeManager:
|
|||||||
raise OrderError(error_messages['internal'])
|
raise OrderError(error_messages['internal'])
|
||||||
|
|
||||||
|
|
||||||
@app.task(base=ProfiledTask, bind=True, max_retries=5, default_retry_delay=1)
|
@app.task(base=ProfiledTask, bind=True, max_retries=5, default_retry_delay=1, throws=(OrderError,))
|
||||||
def perform_order(self, event: str, payment_provider: str, positions: List[str],
|
def perform_order(self, event: str, payment_provider: str, positions: List[str],
|
||||||
email: str=None, locale: str=None, address: int=None, meta_info: dict=None):
|
email: str=None, locale: str=None, address: int=None, meta_info: dict=None):
|
||||||
try:
|
try:
|
||||||
@@ -614,7 +614,7 @@ def perform_order(self, event: str, payment_provider: str, positions: List[str],
|
|||||||
return OrderError(error_messages['busy'])
|
return OrderError(error_messages['busy'])
|
||||||
|
|
||||||
|
|
||||||
@app.task(base=ProfiledTask, bind=True, max_retries=5, default_retry_delay=1)
|
@app.task(base=ProfiledTask, bind=True, max_retries=5, default_retry_delay=1, throws=(OrderError,))
|
||||||
def cancel_order(self, order: int, user: int=None):
|
def cancel_order(self, order: int, user: int=None):
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -9,3 +9,10 @@ from django.conf import settings
|
|||||||
app = Celery('pretix')
|
app = Celery('pretix')
|
||||||
app.config_from_object('django.conf:settings', namespace='CELERY')
|
app.config_from_object('django.conf:settings', namespace='CELERY')
|
||||||
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
|
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
|
||||||
|
|
||||||
|
|
||||||
|
if hasattr(settings, 'RAVEN_CONFIG'):
|
||||||
|
# Celery signal registration
|
||||||
|
from raven.contrib.celery import register_signal
|
||||||
|
from raven.contrib.django.models import client
|
||||||
|
register_signal(client, ignore_expected=True)
|
||||||
|
|||||||
@@ -30,9 +30,11 @@ class PermissionMiddleware(MiddlewareMixin):
|
|||||||
def process_request(self, request):
|
def process_request(self, request):
|
||||||
url = resolve(request.path_info)
|
url = resolve(request.path_info)
|
||||||
url_name = url.url_name
|
url_name = url.url_name
|
||||||
|
|
||||||
if not request.path.startswith(get_script_prefix() + 'control'):
|
if not request.path.startswith(get_script_prefix() + 'control'):
|
||||||
# This middleware should only touch the /control subpath
|
# This middleware should only touch the /control subpath
|
||||||
return
|
return
|
||||||
|
|
||||||
if hasattr(request, 'organizer'):
|
if hasattr(request, 'organizer'):
|
||||||
# If the user is on a organizer's subdomain, he should be redirected to pretix
|
# If the user is on a organizer's subdomain, he should be redirected to pretix
|
||||||
return redirect(urljoin(settings.SITE_URL, request.get_full_path()))
|
return redirect(urljoin(settings.SITE_URL, request.get_full_path()))
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ from django.contrib.messages import constants as messages # NOQA
|
|||||||
from django.utils.crypto import get_random_string
|
from django.utils.crypto import get_random_string
|
||||||
from django.utils.translation import ugettext_lazy as _ # NOQA
|
from django.utils.translation import ugettext_lazy as _ # NOQA
|
||||||
from pkg_resources import iter_entry_points
|
from pkg_resources import iter_entry_points
|
||||||
|
from . import __version__
|
||||||
|
|
||||||
config = configparser.RawConfigParser()
|
config = configparser.RawConfigParser()
|
||||||
config.read(['/etc/pretix/pretix.cfg', os.path.expanduser('~/.pretix.cfg'), 'pretix.cfg'],
|
config.read(['/etc/pretix/pretix.cfg', os.path.expanduser('~/.pretix.cfg'), 'pretix.cfg'],
|
||||||
@@ -205,6 +206,19 @@ for entry_point in iter_entry_points(group='pretix.plugin', name=None):
|
|||||||
PLUGINS.append(entry_point.module_name)
|
PLUGINS.append(entry_point.module_name)
|
||||||
INSTALLED_APPS.append(entry_point.module_name)
|
INSTALLED_APPS.append(entry_point.module_name)
|
||||||
|
|
||||||
|
if config.has_option('sentry', 'dsn'):
|
||||||
|
INSTALLED_APPS += [
|
||||||
|
'raven.contrib.django.raven_compat',
|
||||||
|
]
|
||||||
|
DISABLE_SENTRY_INSTRUMENTATION = True # see celery.py for more, we use this differently
|
||||||
|
RAVEN_CONFIG = {
|
||||||
|
'dsn': config.get('sentry', 'dsn'),
|
||||||
|
'transport': 'raven.transport.threaded_requests.ThreadedRequestsHTTPTransport',
|
||||||
|
'release': __version__,
|
||||||
|
'environment': SITE_URL,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
CORE_MODULES = {
|
CORE_MODULES = {
|
||||||
("pretix", "base"),
|
("pretix", "base"),
|
||||||
("pretix", "presale"),
|
("pretix", "presale"),
|
||||||
|
|||||||
@@ -29,4 +29,4 @@ csscompressor
|
|||||||
django-markup
|
django-markup
|
||||||
markdown
|
markdown
|
||||||
bleach
|
bleach
|
||||||
|
raven
|
||||||
|
|||||||
Reference in New Issue
Block a user