Run arbirary scripts with sentry_sdk initialized to some DSN on the fly
Project description
dsnrun
Ad hoc utility to rerun a Python script, but with the sentry_sdk initialized
to a specific DSN.
Bring the awesome experience of your error tracking software to ad hoc scripts and tools, non-production scripts and scripts that you cannot easily edit.
Installation & Usage
$ pip install dsnrun
[...]
$ dsnrun -h
Usage: dsnrun [dsn] [-m module | filename] [args...]
To use this, just rewrite your python invocations, i.e.
#!bash
# normal Python
$ python -m failingmodule
[..stacktrace..]
# becomes
$ dsnrun -m failingmodule
#!bash
# normal Python
$ python /tmp/failingmodule.py
[..stacktrace..]
# becomes
$ dsnrun /tmp/failingmodule.py
Now, visit your Error Tracker and get a much prettier stacktrace (including local variables).
Rationale
At Bugsink, we like our Error Tracking so much, that we even use it for local development. (Why wouldn't we: setup is trivial).
If you like Python, you probably do a lot with Python, including things for which you dind't plan on setting up your Error Tracker. Still, you occasionally mess up, leading to a stack trace on-screen.
What if that stacktrace was as awesome as the one in your error tracker?
Features
- Because we use
runpyto run the script, it should work with any Python script that you can run withpython -morpython filename.py. i.e. anyif __name__ == '__main__':block will still work as expected.
Limitations
Don't use this to set up sentry_dsn for your actual production code. We
shouldn't have to explain why, but the gist of it is: There may very well be
edge cases that trip this thing up, and why would you break production if you
can just add a few lines to your actual production code?
These are current limitations, meaning we might as well improve the script if it turns out to be useful:
-
the on-screen (printed) stacktrace for
dsnrunis not equal to the regular-python version; it also containsdsnrunitself and the functions it invokes. The event as sent to your DSN does not contain these though (we prune it). -
dsnis the only currently supported argument tosentry_sdk.init. For future versions I'll put in the work of translating CLI args to SDK args. -
dsnrun manually patches
sys.argvsuch that the invoked script does not getdsnrun's arguments passed to it. This "seems to work" (but may not generally work). However, I did not find a way to "properly do this". See https://bugs.python.org/issue26388 -
If you mistype the thing-to-run you'll send an
ImportErrorto your DSN. This is not filtered out (yet). Examples:
ImportError: No module named nosuchmodule
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/nosuchfile.py'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dsnrun-0.1.0.tar.gz.
File metadata
- Download URL: dsnrun-0.1.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cea002cee0ac206f87b6316225c8372175fb4a7f2e42fc04797d93d2d2dc3906
|
|
| MD5 |
4923a99e6f8ec8ad59d33b43d8d111b8
|
|
| BLAKE2b-256 |
d16a46709eede1590ffb01de8f9722d649b05a5537f33da4a360caffe4f3874d
|
File details
Details for the file dsnrun-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dsnrun-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ad3e74eb2bd3998be9f23fbad9bb19b57dc1e4f149c7cabb26d9dd70c3bd620
|
|
| MD5 |
02ccbe0f7de958578183ea1cf4132ec3
|
|
| BLAKE2b-256 |
b5814473159281e6a335296c598c2e014f04a36c622ceac010fa4b7955fd669b
|