danielwelch / django-q-sentry Goto Github PK
View Code? Open in Web Editor NEWBringing Sentry error tracking to Django Q
License: MIT License
Bringing Sentry error tracking to Django Q
License: MIT License
Hi there,
I'm trying to follow the Installation instructions in the README, but I'm getting an error. Below is the output from pip install django-q[sentry]
(venv) Jordans-15-MBP:my_project jordan$ pip install django-q[sentry]
Requirement already satisfied: django-q[sentry] in ./venv/lib/python3.5/site-packages
Requirement already satisfied: arrow in ./venv/lib/python3.5/site-packages (from django-q[sentry])
Requirement already satisfied: django-picklefield in ./venv/lib/python3.5/site-packages (from django-q[sentry])
Requirement already satisfied: blessed in ./venv/lib/python3.5/site-packages (from django-q[sentry])
Requirement already satisfied: django>=1.8 in ./venv/lib/python3.5/site-packages (from django-q[sentry])
Collecting django-q-sentry>=0.1; extra == "sentry" (from django-q[sentry])
Could not find a version that satisfies the requirement django-q-sentry>=0.1; extra == "sentry" (from django-q[sentry]) (from versions: )
No matching distribution found for django-q-sentry>=0.1; extra == "sentry" (from django-q[sentry])
I actually can't seem to find django-q-sentry
on https://pypi.python.org so I'm thinking the issue might be that the package hasn't been published to PyPI yet? Any suggestions?
If you follow the current docs for using Sentry with Python/Django you will add something like the following code to your settings.py:
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
sentry_sdk.init(
dsn="https://[email protected]/1234",
integrations=[DjangoIntegration()],
traces_sample_rate=0.05,
send_default_pii=True,
release="[email protected]",
)
If you then follow the django-q-sentry docs, you will also add this:
Q_CLUSTER {
# ...
'error_reporter': {
'sentry': {
'dsn': SENTRY_DSN
}
}
}
The problem is that doing this will break your earlier config. In particular, I noticed that the performance tracing was not working at all - Sentry was not receiving any performance traces. When I disabled the error_report
key in the Q_CLUSTER
setting, it started working.
Digging it, it looks like django-q-sentry does its own call to sentry_sdk.init
in
django-q-sentry/django_q_sentry/sentry.py
Line 45 in c2d0846
With django-q-sentry disabled, it appears that Sentry works just fine for reporting crashes inside my tasks. So is django-q-sentry needed at all? Would it be best to deprecate this package?
When configuring Sentry normally, one can pass the before send
function to filter or manipulate events client side before sending to Sentry. Does the config json inside of the django q config for sentry accept the before_send
field?
Hi,
I am porting django-q-sentry as an optional dependency of django-q on FreeBSD, but I noticed that it packages from a directory called /home/goose
and even contains a .venv
directory. Commonly it should contain the source tree with an setup.py
or a pyproject.toml
.
$ tar tf django-q-sentry-0.1.6.linux-x86_64.tar.gz
./
./home/
./home/goose/
./home/goose/Development/
./home/goose/Development/django-q-sentry/
./home/goose/Development/django-q-sentry/.venv/
./home/goose/Development/django-q-sentry/.venv/lib/
./home/goose/Development/django-q-sentry/.venv/lib/python3.9/
./home/goose/Development/django-q-sentry/.venv/lib/python3.9/site-packages/
./home/goose/Development/django-q-sentry/.venv/lib/python3.9/site-packages/django_q_sentry/
./home/goose/Development/django-q-sentry/.venv/lib/python3.9/site-packages/django_q_sentry/__init__.py
./home/goose/Development/django-q-sentry/.venv/lib/python3.9/site-packages/django_q_sentry/__pycache__/
./home/goose/Development/django-q-sentry/.venv/lib/python3.9/site-packages/django_q_sentry/__pycache__/__init__.cpython-39.pyc
./home/goose/Development/django-q-sentry/.venv/lib/python3.9/site-packages/django_q_sentry/__pycache__/sentry.cpython-39.pyc
./home/goose/Development/django-q-sentry/.venv/lib/python3.9/site-packages/django_q_sentry/sentry.py
./home/goose/Development/django-q-sentry/.venv/lib/python3.9/site-packages/django_q_sentry-0.1.6-py3.9.egg-info/
./home/goose/Development/django-q-sentry/.venv/lib/python3.9/site-packages/django_q_sentry-0.1.6-py3.9.egg-info/PKG-INFO
./home/goose/Development/django-q-sentry/.venv/lib/python3.9/site-packages/django_q_sentry-0.1.6-py3.9.egg-info/SOURCES.txt
./home/goose/Development/django-q-sentry/.venv/lib/python3.9/site-packages/django_q_sentry-0.1.6-py3.9.egg-info/dependency_links.txt
./home/goose/Development/django-q-sentry/.venv/lib/python3.9/site-packages/django_q_sentry-0.1.6-py3.9.egg-info/requires.txt
./home/goose/Development/django-q-sentry/.venv/lib/python3.9/site-packages/django_q_sentry-0.1.6-py3.9.egg-info/top_level.txt
An attempt is made to ignore internal logging from Django-Q itself in
django-q-sentry/django_q_sentry/sentry.py
Lines 7 to 9 in 6ed0b37
This doesn't seem to work however: in Sentry I'm receiving ERROR log messages about failed tasks in Django (generated at https://github.com/django-q2/django-q2/blob/7fb7fca176eceb5112196b6620cd336a616124df/django_q/monitor.py#L57-L65)
After some research I'm now trying to suppress these in a Sentry before_send
hook:
def before_send(event, hint):
"""Suppress certain events from being submitted to Sentry"""
if "log_record" in hint:
rec = hint["log_record"]
if rec.name == "django-q":
# See https://github.com/django-q2/django-q2/blob/7fb7fca176eceb5112196b6620cd336a616124df/django_q/monitor.py#L58 # noqa: E501
logger.info("Suppressing Sentry event submission for Django-Q internals")
return None
return event
It would be nice if this would work out if the box.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.