About Sentry
Sentry is an event logging platform primarily focused on capturing and aggregating exceptions, with a commercial service at
https://getsentry.com.
The Sentry client lib for Ruby (
sentry-raven
) will send not all logs, but only crash reports, with a big pack of data. You can add more data, like current user and tags (
more details). At the Sentry server, this reports are grouped and displayed like a issue tracker, where you can comment, resolve, filter… and also be notified by new kind of crashes and regressions.
One big benefit is to not depend on consumers to notified about errors.
Installing Sentry
This install steps are based on
https://docs.getsentry.com/on-premise/server/installation and is focused for Debian GNU/Linux.
For more details, read:
https://sentry.readthedocs.org/en/stable/getting-started/index.html
You should run this lines as root:
# Install python package installer and other dependencies
aptitude install python-dev python-pip python-libxml2 python-libxslt1 libxslt1-dev libxml2-dev libffi-dev redis-server postgresql libpq-dev
pip install --upgrade setuptools
pip install --upgrade funcsigs
# Install Sentry with PIP
pip install --upgrade sentry
# Install Postgres support
pip install --upgrade sentry[postgres]
# Create config
mkdir /etc/sentry
sentry init /etc/sentry/sentry.conf.py
Configure Sentry Server
Edit
/etc/sentry/sentry.conf.py
and update this variables:
'ENGINE': 'sentry.db.postgres',
'NAME': 'sentry',
'USER': 'sentry',
'PASSWORD': '********',
'HOST': 'localhost',
'PORT': '5433',
…
SENTRY_URL_PREFIX = 'http://my.domain.xyz' # No trailing slash!
…
SENTRY_ADMIN_EMAIL = 'sentry@my.domain.xyz'
…
EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
EMAIL_FILE_PATH = '/tmp/sentry-mail'
# Mail conf docs: https://docs.djangoproject.com/en/1.8/topics/email/
Build the Database
Create…
su postgres -c 'createuser sentry --no-superuser --createdb --no-createrole -P'
su postgres -c 'createdb -E utf-8 sentry -O sentry'
Apply the DB shema
SENTRY_CONF=/etc/sentry/sentry.conf.py sentry upgrade
On the first update
sentry
will ask you for admin email and password, interactively. That means i don't know how to make the 100% installation automatic.
Run!
Run as
www-data
or your preferred user for web services.
SENTRY_CONF=/etc/sentry/sentry.conf.py sentry start
It is working at
http://localhost:9000 To change the domain and port edit
/etc/sentry/sentry.conf.py
Start the worker
SENTRY_CONF=/etc/sentry/sentry.conf.py sentry celery worker -B
Congratulations. You have a working Sentry server.
Cleanup Old Data
Add to your crontab:
0 3 * * * sentry cleanup --days=30
Adding Sentry support to Noosfero
(it is a concept proof yet)
This doc is a simple and direct quick start. For more details read:
Install
sentry-raven
:
gem install sentry-raven
(With gem while we do not pack sentry-raven)
Add to
Gemfile
:
gem 'sentry-raven', '~> 0.15.2'
Add to
evironment.rb
:
Raven.configure do |config|
config.environments = ['development', 'production']
end
Add to
initializers/sentry.rb
:
Raven.configure do |config|
config.dsn = 'http://<secret>@sentry.domain.xyz/<projet-id>'
config.sanitize_fields = Rails.application.config.filter_parameters.map(&:to_s)
end
Using Raven
# Set the user somewhere. May be on a root controller class.
Raven.user_context identifier: user.identifier, email: user.email if user
# Add context to raven setting tags over the code.
Raven.tags_context profile_type: 'big community'
# You can send a report for Sentry without a crash using methods like this:
Raven.capture_message 'Shit happens'