Crates.io | airbrake |
lib.rs | airbrake |
version | 0.2.0 |
source | src |
created_at | 2016-05-29 17:10:13.214402 |
updated_at | 2017-05-13 20:52:38.514608 |
description | Airbrake Rust is an Airbrake (https://airbrake.io) notifier library for the Rust Programming language. The library provides minimalist API that enables the ability to send Rust errors to the Airbrake dashboard. |
homepage | https://github.com/kyrylo/airbrake-rust |
repository | https://github.com/kyrylo/airbrake-rust |
max_upload_size | |
id | 5226 |
size | 21,132 |
*/!\ The project is in the alpha stage /!*
Airbrake Rust is an Airbrake notifier library for the Rust Programming language. The library provides minimalist API that enables the ability to send Rust errors to the Airbrake dashboard.
Add the crate to your Cargo.toml:
[dependencies]
airbrake = "0.2"
This is the minimal example that you can use to test Airbrake Rust with your project:
extern crate airbrake;
use std::num::ParseIntError;
fn double_number(number_str: &str) -> Result<i32, ParseIntError> {
number_str.parse::<i32>().map(|n| 2 * n)
}
fn main() {
let mut airbrake = airbrake::configure(|config| {
config.project_id = "113743".to_owned();
config.project_key = "81bbff95d52f8856c770bb39e827f3f6".to_owned();
});
match double_number("NOT A NUMBER") {
Ok(n) => assert_eq!(n, 20),
// Asynchronously sends the error to the dashboard.
Err(err) => airbrake.notify(err),
}
// Joins worker threads.
airbrake.close();
}
You must set both project_id
& project_key
.
To find your project_id
and project_key
navigate to your project's General
Settings and copy the values from the right sidebar.
let mut airbrake = airbrake::configure(|config| {
config.project_id = "113743".to_owned();
config.project_key = "81bbff95d52f8856c770bb39e827f3f6".to_owned();
});
By default, it is set to https://airbrake.io
. A host
is a web address
containing a scheme ("http" or "https"), a host and a port. You can omit the
port (80 will be assumed).
let mut airbrake = airbrake::configure(|config| {
config.host = "http://localhost:8080".to_owned();
});
The number of threads that handle notice sending. The default value is 1.
let mut airbrake = airbrake::configure(|config| {
config.workers = 5;
});
If your server is not able to directly reach Airbrake, you can use proxy support. By default, Airbrake Rust uses direct connection. Note: proxy authentication is not supported yet.
let mut airbrake = airbrake::configure(|config| {
config.proxy = "127.0.0.1:8080".to_owned();
});
The version of your application that you can pass to differentiate errors between multiple versions. It's not set by default.
let mut airbrake = airbrake::configure(|config| {
config.app_version = "1.0.0".to_owned();
});
Sends an error to Airbrake asynchronously. error
must implement the
std::error::Error
trait. Returns ()
.
let mut airbrake = airbrake::configure(|config| {
config.project_id = "123".to_owned();
config.project_key = "321".to_owned();
});
airbrake.notify(std::io::Error::last_os_error());
Sends an error to Airbrake synchronously. error
must implement the
std::error::Error
trait. Returns
rustc_serialize::json::Json
. Accepts the same
parameters as Airbrake.notify
.
let mut airbrake = airbrake::configure(|config| {
config.project_id = "123".to_owned();
config.project_key = "321".to_owned();
});
airbrake.notify_sync(std::io::Error::last_os_error());