Skip to content

Report failed processes/scripts to Sentry

License

Notifications You must be signed in to change notification settings

dsferruzza/sentry-process

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sentry Process

LICENSE pipeline status Crates.io Version Minimum rustc version Get help on Codementor

Report failed processes/scripts to Sentry.

⚠️ Main repository is here: https://gitlab.com/dsferruzza/sentry-process ⚠️

Motivation

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!

How to use

  • compile or install the project
  • set the SENTRY_DSN environment variable (use the URL given in Your project > Settings > Client Keys (DSN) in Sentry)
  • run sentry-process COMMAND [ARGUMENTS]... (wrap your process call like you would do with sudo)

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.

Rust Version Requirements

Sentry Process needs Rust 1.54+ to be compiled.

Limitations

  • 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.

License

MIT License Copyright (c) 2019 David Sferruzza