Skip to content

Commit 1790b0e

Browse files
Add Sentry monitoring for Trac (#134)
1 parent 6376e60 commit 1790b0e

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

DjangoPlugin/tracdjangoplugin/wsgi.py

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import os
2+
13
import trac.web.main
24
application = trac.web.main.dispatch_request
35

@@ -8,3 +10,18 @@
810

911
from .djangoauth import DjangoAuth
1012
application = DjangoAuth(application)
13+
14+
trac_dsn = os.getenv("SENTRY_DSN")
15+
16+
if trac_dsn:
17+
import sentry_sdk
18+
from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware
19+
sentry_sdk.init(
20+
dsn=trac_dsn,
21+
22+
# Set traces_sample_rate to 1.0 to capture 100%
23+
# of transactions for performance monitoring.
24+
# We recommend adjusting this value in production,
25+
traces_sample_rate=0.2,
26+
)
27+
application = SentryWsgiMiddleware(application)

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ ENV DJANGO_SETTINGS_MODULE=tracdjangoplugin.settings TRAC_ENV=/code/trac-env/
5959
ENTRYPOINT ["/code/docker-entrypoint.sh"]
6060

6161
# Start gunicorn
62-
CMD ["/venv/bin/newrelic-admin", "run-program", "/venv/bin/gunicorn", "tracdjangoplugin.wsgi:application", "--bind", "0.0.0.0:9000", "--workers", "8", "--max-requests", "1000"]
62+
CMD ["/venv/bin/gunicorn", "tracdjangoplugin.wsgi:application", "--bind", "0.0.0.0:9000", "--workers", "8", "--max-requests", "1000"]

requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ requests-oauthlib==1.0.0
1717
trac-github==2.3
1818

1919
gunicorn==19.10.0
20-
newrelic
20+
sentry-sdk==1.11.0
2121

2222
-e ./DjangoPlugin

0 commit comments

Comments
 (0)