Day 29 Dev Notes
Had some fun this evening. I installed a self-hosted error-tracking application called GlitchTip. It's written in Python and Django and is compatible with Sentry - in fact, to integrate the error reporting into your app, you install the Sentry SDK and configure the DSN to a GlitchTip-specific URL for your own installation.
Installation was fairly straight forward. The Docker compose file they provided was easy to modify for Portainer, but there were a couple of undocumented settings that I had to figure out along the way. But once it was up and running, it was easy to set up the projects and get the client reporting errors.
I updated the Bus Times app and my stuartm.nz site to report errors to GlitchTip, along with perfomance monitoring stats. Here's a code snippet for how I added this to my settings.py
file:
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
env = environ.Env(
...
SENTRY_DSN=(str, ""),
SENTRY_ENVIRONMENT=(str, "development"),
SENTRY_TRACES_SAMPLE_RATE=(float, 0.0),
...
)
SENTRY_DSN = env("SENTRY_DSN")
if SENTRY_DSN:
sentry_sdk.init(
dsn=env("SENTRY_DSN"),
integrations=[DjangoIntegration()],
environment=str(env("SENTRY_ENVIRONMENT")),
traces_sample_rate=env("SENTRY_TRACES_SAMPLE_RATE"),
)