Report failed processes/scripts to Sentry.
Sentry is a cool system that helps developers to aggregate, monitor and fix errors/exceptions in their own apps. It has integrations for many technologies so that reported errors can contain relevant informations.
But sometimes it can be desirable to plug Sentry to an arbitrary process. Such process can be a binary that was built without Sentry support, or a Bash script that runs every night on a server, for example.
With Sentry Process it is now easy to launch a process that will send an event to a Sentry instance whenever it fails!
- compile or install the project
- set the
SENTRY_DSN
environment variable (use the URL given inYour project > Settings > Client Keys (DSN)
in Sentry) - run
sentry-process COMMAND [ARGUMENTS]...
(wrap your process call like you would do withsudo
)
If running COMMAND [ARGUMENTS]...
results in an exit code that is not 0
, Sentry Process considers it as a failure and reports. For example, sentry-process false
will report whereas sentry-process true
will not.
The exit code, standard output and standard error of COMMAND [ARGUMENTS]...
are re-emmited by sentry-process COMMAND [ARGUMENTS]...
, so that it can be piped or used by other programs. In fact, standard output and standard error are streamed so you can run (for example) sentry-process wget https://somebigfileurl
and see the progress just like if you had run wget https://somebigfileurl
.
Sentry Process needs Rust 1.54+ to be compiled.
- The process you want to run must terminate eventually. It may not make sense to use Sentry Process with processes that are designed to never die (like servers).
- You will not get much details on what failed (i.e. no stacktraces). This is the tradeoff here.
- Sentry Process will send to your Sentry instance both standard output (
stdout
) and standard error (stderr
) of the process you want to run (if it fails). Your Sentry instance might reject the report if this data is more than 200 kB (see Sentry's documentation), so Sentry Process uses a circular buffer to ensure that this limit cannot be reached and the most recent outputs are sent with the report.
MIT License Copyright (c) 2019 David Sferruzza