Skip to content

G3W-SUITE module for application performance monitoring and error tracking via sentry.io

License

Notifications You must be signed in to change notification settings

g3w-suite/g3w-admin-sentry-monitor

Repository files navigation

G3W-ADMIN-SENTRY-MONITOR v0.0.1

G3W-SUITE module for application performance monitoring and error tracking via sentry.io.

sentry-dashboard

Installation

Install sentry_monitor module into g3w-admin applications folder:

# Install module from github (v1.0.0)
pip3 install git+https://github.com/g3w-suite/g3w-admin-sentry-monitor.git@v1.0.0

# Install module from github (master branch)
# pip3 install git+https://github.com/g3w-suite/g3w-admin-sentry-monitor.git@master

# Install module from local folder (git development)
# pip3 install -e /shared-volume/g3w-admin-sentry-monitor

# Install module from PyPi (not yet available)
# pip3 install g3w-admin-sentry-monitor

Enable 'sentry_monitor' module adding it to G3W_LOCAL_MORE_APPS list:

# local_settings.py

G3WADMIN_LOCAL_MORE_APPS = [
    ...
    'sentry_monitor'
    ...
]

Refer to g3w-suite-docker repository for more info about running this on a docker instance.

NB On Ubuntu Jammy you could get an UNKNOWN package install instead of g3w-admin-sentry-monitor, you can retry installing it as follows to fix it:

# Fix: https://github.com/pypa/setuptools/issues/3269#issuecomment-1254507377
export DEB_PYTHON_INSTALL_LAYOUT=deb_system

# And then install again the module
pip3 install ...

Configuration

The following packages are included in this module:

Refer to the official docs for a more comprehensive list of the available settings:

# Update your Sentry project DSN (Data Source Name)
#
# see: https://docs.sentry.io/product/sentry-basics/dsn-explainer/
# -------------------------------------------

SENTRY_JS_DSN = "https://your-javascript-dsn@sentry.example.com/1"
SENTRY_PY_DSN = "https://your-python-dsn@sentry.example.com/2"
<!--
  Include javascript tracking script within all html pages you want to monitor

  see: https://docs.djangoproject.com/en/2.2/topics/templates/#the-django-template-language
-->
<html>
<body>
   ...
  {% if SETTINGS.SENTRY_JS %}
    {{ SETTINGS.SENTRY_JS | safe }}
  {% endif %}
  ...
</html>

For the default settings currently applied by this module, see also: sentry_monitor/apps.py

Check tracker integration

Intentionally trigger a javascript error within a django page (html template) and then login into your sentry.io account for viewing the trace log

<html>
<body>
   ...
  {% if SETTINGS.SENTRY_JS %}
    {{ SETTINGS.SENTRY_JS | safe }}
  {% endif %}
  ...
  <script>
    myUndefinedFunction(); // Intentionally trigger a javascript error
  </script>
</html>

Contributing

Steps to follow for local development of this module.

Clone g3w-admin and g3w-admin-sentry-monitor repositories into two adjacent folders:

cd /path/to/your/development/workspace

git clone https://github.com/g3w-suite/g3w-admin.git
git clone https://github.com/g3w-suite/g3w-admin-sentry-monitor.git

So your folder structure should matches the following:

.
├── g3w-admin/
│   ├── g3w-admin/
│   │   ├── base/
│   │   ├── core/
│   │   ├── ...
│   │   └── manage.py
│   └── README.md
│
└── g3w-admin-sentry-monitor/
    ├── sentry_monitor/
    │   ├── __init__.py
    │   ├── apps.py
    │   ├── urls.py
    │   ├── views.py
    │   └── ...
    ├── pyproject.toml
    └── README.md

Install the g3w-admin-sentry-monitor module in editable mode starting from your g3w-admin folder:

cd g3w-admin

python3 -m pip install -e ../g3w-admin-sentry-monitor

Then activate the 'sentry_monitor' module as usual by adding it to G3W_LOCAL_MORE_APPS list.

Publish

Create a new git tag that is appropriate for the version you intend to publish, eg:

git tag -a v1.0.1
git push origin v1.0.1
Publishing on the Python Package Index

Steps to follow when releasing a new software version on PyPi.

First make sure you have the latest versions of pip, build and twine installed:

python3 -m pip install --upgrade pip
python3 -m pip install --upgrade build
python3 -m pip install --upgrade twine

Build the dist folder starting from the same directory where pyproject.toml is located:

python3 -m build

Upload all to PyPI and verify things look right:

twine upload dist/*

TODO

Find out a way to install this module through the INSTALLED_APPS (ie. much earlier than G3W_LOCAL_MORE_APPS) variable in order to correctly activate the monitoring python as well (ref: SENTRY_PY_DSN).

# local_settings.py

from django.conf import settings

# As per g3w-admin@v3.5 the below variable assignment is currently not
# possible because the INSTALLED_APPS variable is alwayse overridden 
# regardless of the value assigned in here

INSTALLED_APPS = ['sentry_monitor'] + settings.INSTALLED_APPS

# A temporary workaround could be using the THIRD_PARTY_APPS variable:

THIRD_PARTY_APPS = ['sentry_monitor'] + settings.THIRD_PARTY_APPS
# /g3w-admin/g3w-admin/base/settings/__init__.py#L14 (v3.5)

INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + G3WADMIN_APPS + G3WADMIN_PROJECT_APPS

Related resources

Sentry integrations:


Compatibile with: g3w-admin version g3w-suite-docker version


License: MPL-2

About

G3W-SUITE module for application performance monitoring and error tracking via sentry.io

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published