Browse Source

Enable Sentry reporting with INI setting

merge-requests/55/head
Deimos 6 years ago
parent
commit
b91ffe68ea
  1. 3
      tildes/production.ini.example
  2. 5
      tildes/tildes/__init__.py

3
tildes/production.ini.example

@ -18,6 +18,9 @@ redis.sessions.timeout_trigger = 0
# set session timeout to 1 hour by default, we'll extend it when people log in # set session timeout to 1 hour by default, we'll extend it when people log in
redis.sessions.timeout = 3600 redis.sessions.timeout = 3600
# this should only be set if you have a Sentry instance you want to send errors to
sentry_dsn = https://key@sentry.io/project
sqlalchemy.url = postgresql+psycopg2://tildes:@:6432/tildes sqlalchemy.url = postgresql+psycopg2://tildes:@:6432/tildes
tildes.default_user_comment_label_weight = 1.0 tildes.default_user_comment_label_weight = 1.0

5
tildes/tildes/__init__.py

@ -11,6 +11,8 @@ from pyramid.httpexceptions import HTTPTooManyRequests
from pyramid.registry import Registry from pyramid.registry import Registry
from pyramid.request import Request from pyramid.request import Request
from redis import Redis from redis import Redis
import sentry_sdk
from sentry_sdk.integrations.pyramid import PyramidIntegration
from webassets import Bundle from webassets import Bundle
from tildes.lib.ratelimit import RATE_LIMITED_ACTIONS, RateLimitResult from tildes.lib.ratelimit import RATE_LIMITED_ACTIONS, RateLimitResult
@ -59,6 +61,9 @@ def main(global_config: Dict[str, str], **settings: str) -> PrefixMiddleware:
config.add_request_method(current_listing_base_url, "current_listing_base_url") config.add_request_method(current_listing_base_url, "current_listing_base_url")
config.add_request_method(current_listing_normal_url, "current_listing_normal_url") config.add_request_method(current_listing_normal_url, "current_listing_normal_url")
if settings.get("sentry_dsn"):
sentry_sdk.init(dsn=settings["sentry_dsn"], integrations=[PyramidIntegration()])
app = config.make_wsgi_app() app = config.make_wsgi_app()
force_port = global_config.get("prefixmiddleware_force_port") force_port = global_config.get("prefixmiddleware_force_port")

Loading…
Cancel
Save