Skip to main content

A Django app to collect sentry errors in local database, render in a simplified UI similar to Sentry

Project description

minisentry

A Django reusable app to extend sentry-sdk with ability to collect errors in local database rather than send to sentry. An admin panel is provided to browse grouped issues.

This app is useful when for some reason you cannot use sentry.io interface, maybe you can't send data to third party vendors, maybe you can't have a self-hosted version.

This is a very simple app, it hooks into sentry_sdk.init.before_send function, serializes the events into json and stores them in the database.

Thjs app is written in rush to get first working version out, I test the app in my application and only maybe will add automatic tests if it gets used.

I analysed the datastructures emitted by sentry-sdk and hae some confidence that I didn't miss anything. The app will store the raw event as a whole, so if I missed anything, corrections to the main template should be enough. It is a recoverbale mistake.

This app will obviously only work for errors that don't relate to database connection itself. You have to have working django and connection to store them.

Versioning: calver, I only care for the most recent version of sentry-sdk, python and django, but likely it will work with some lower versions.

I start with implementing only what I need, with time I will add more stuff.

install

pip install django-minisentry

# settings.py
INSTALLED_APPS = [
    ...,
    'minisentry'
]

# urls.py
urlpatterns = [
    ...
    path('minisentry/', include('minisentry.urls')),
    ...
]

# wherever you setup sentry_sdk
from minisentry import store
sentry_sdk.init(
    ...,
    before_send = store(
        send=False,            # default 
        event_callback=print,  # maybe for debug
        hint_callback=print,   # maybe for debug
        ignore_errors=(ZeroDivisionError, KeyboardInterrupt)
    )
)

develop

git clone https://github.com/bartekbrak/django-minisentry
pip install -e django-minisentry

legal

Dear Sentry, please don't sue me. This project is for people who cannot use your wonderful, best-in-class product. I'm your biggest fan and evangelise your paid version where I can. This all is in good faith, but it does abuse your SDK, you didn't build it so that we can store your events elsewhere. Thanks.

todo

  • tests
  • backlinks, in admin, in browse
  • search
  • graph on issue list
  • x minutes ago
  • permissions?
  • colours
  • stringify2 needs to escape html
  • management commands to delete old
  • storage information, sizes
  • clean css
  • prettify sql

based on

build and release (to myself)

pip install -e .
pip install -U setuptools wheel build twine
rm dist/*
# change "version = ????????" in setup.cfg 
python -m build --wheel
twine check dist/*
twine upload dist/*

changelog

  • 2023-08-24 handle logger.error
  • 2023-08-17 display tags set via sentry_sdk.set_tag("sth", "sth")
  • 2023-08-11 ignore_errors, expand README
  • 2023-08-10 rename to minisentry
  • 2023-08-04 first rushed alpha version

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

django_minisentry-20230824-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file django_minisentry-20230824-py3-none-any.whl.

File metadata

File hashes

Hashes for django_minisentry-20230824-py3-none-any.whl
Algorithm Hash digest
SHA256 695b3cff11f12806674d364ff685933197ed58d298b40906f3b231343a176676
MD5 8fbb979b9a63c71ca4452778053e3d9d
BLAKE2b-256 ecfd321d83724a3b61f2f6dc9dd23830c28c56b50e2fd240b9a30bb51cb5fe95

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page