#rocket-web #sentry #rocket #monitoring #web-apps #web-framework #error-reporting

rocket-sentry

Simplifies integration between the Rocket web framework and Sentry application monitoring system

16 breaking releases

0.17.0 Nov 28, 2023
0.15.0 Feb 25, 2023
0.13.0 Nov 7, 2022
0.11.0 May 22, 2022
0.1.0 Nov 24, 2019

#1037 in Web programming

Download history 18/week @ 2023-12-18 12/week @ 2024-01-22 12/week @ 2024-02-19 30/week @ 2024-02-26 109/week @ 2024-03-04 22/week @ 2024-03-11 31/week @ 2024-03-18 19/week @ 2024-03-25 43/week @ 2024-04-01

128 downloads per month

MIT license

24KB
231 lines

Rocket Sentry

Crates.io version Documentation Tests status Changelog

rocket-sentry is a simple add-on for the Rocket web framework to simplify integration with the Sentry application monitoring system.

Or maybe...

"The Rocket Sentry is a static rocket-firing gun platform that is based on a Personality Construct and used in the Aperture Science Enrichment Center."

-- Half-Life wiki

Features

Currently rocket-sentry includes two integrations:

  • Rust panic handler: when a panic happens, it is reported as a Sentry event.

  • Performance Monitoring: HTTP requests are reported as Transactions, if the sentry_traces_sample_rate setting is configured.

    Transactions currently include the following fields:

    • HTTP method
    • GET query string
    • headers
    • POST data
    • cookies
    • environment
    • URL

Pull requests welcome!

Usage

rocket-sentry can be configured via Rocket.toml (sentry_dsn=) or environment variable ROCKET_SENTRY_DSN.

To use this, add the dependency to your Cargo.toml, and add the fairing to your code:

use rocket_sentry::RocketSentry;

#[launch]
fn rocket() -> _ {
    rocket::build()
        .attach(RocketSentry::fairing())
        // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^   add this line
}

Then, the Sentry integration can be enabled by adding a sentry_dsn= value to the Rocket.toml file, for example:

[debug]
sentry_dsn = ""  # Disabled
[release]
sentry_dsn = "https://057006d7dfe5fff0fbed461cfca5f757@sentry.io/1111111"
sentry_traces_sample_rate = 0.2  # 20% of requests will be logged under the performance tab

Testing

The functionality can be tested with the examples/panic.rs example. Just change the Rocket.toml file and run it...

cargo run --example panic

Then try accessing this URL: http://localhost:8012/panic?msg=Is+it+time+to+panic+yet?

Dependencies

~18–54MB
~1M SLoC