Skip to content

Latest commit

 

History

History
54 lines (35 loc) · 1.76 KB

README.md

File metadata and controls

54 lines (35 loc) · 1.76 KB

A minimal Django app for running sentry along with structlog json logging setup

JSON structured messages make Sentry issues and breadcrumbs hard to read, but are great for parsing and aggregating in ELK stack. We do some hacking around with structlog and sentry internals to make them work together nicely

  • Send plain text string log events instead of json/dict events to Sentry
  • Send plain text string breadcrumb events instead of json/dict events to Sentry
  • Save traceback to LogRecord.exc_info when using structlog so Sentry can extract it
  • Allow copying custom keys from event_dict to LogRecord attributes so Sentry can put it as extra (E.g. see request_id in the above screenshot)
  • Get '_meta' key in Sentry event json when using structlog

Other related projects that attempt to solve this problem:


To run (sorry no docker or uwsgi here):

Needs Python 3.6+

  1. Install requirements (preferrably in a virtual environment)

    pip install -r requirements.txt
  2. Sign up for sentry, create a project and get a DSN

  3. Copy .env.template to .env

    cp .env.template .env
  4. Edit .env with your favorite editor and paste your Sentry DSN

    SENTRY_DSN=https://{...}@{...}.ingest.sentry.io/{...}
    
  5. Run the dev server

    python manage.py runserver 0.0.0.0:8000
  6. Go create errors

  7. Go explore the code at setup_logs and setup_sentry