Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kyrylo/airbrake-rust
WIP
https://github.com/kyrylo/airbrake-rust
Last synced: 3 days ago
JSON representation
WIP
- Host: GitHub
- URL: https://github.com/kyrylo/airbrake-rust
- Owner: kyrylo
- License: mit
- Created: 2016-05-28T16:11:45.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-05-27T06:59:03.000Z (over 2 years ago)
- Last Synced: 2024-12-27T14:51:38.078Z (9 days ago)
- Language: Rust
- Size: 117 KB
- Stars: 5
- Watchers: 4
- Forks: 3
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Airbrake Rust
=============[![Build Status](https://travis-ci.org/kyrylo/airbrake-rust.svg?branch=master)](https://travis-ci.org/kyrylo/airbrake-rust)
**The project is in the alpha stage and I don't recommend using it in
production until it hits v1.0.0**. See the [v0.2.0 tag](https://github.com/kyrylo/airbrake-rust/tree/422147119de3ba16ca8915fef2ac8f50b74526bf) for documentation for the current latest release of this project.* [Airbrake Rust README](https://github.com/kyrylo/airbrake-rust)
Introduction
------------_Airbrake Rust_ is an [Airbrake][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.Key features
------------* Uses the new Airbrake JSON API (v3)[[link][notice-v3]]
* Simple, consistent and easy-to-use library API[[link](#api)]
* Awesome performance (check out our benchmarks)[[link](#running-benchmarks)]
* Asynchronous error reporting[[link](#asynchronous-airbrake-options)]
* Logging support via env_logger[[link][env_logger]]
* Support for proxying (WIP)[[link](#proxy)]
* Support for environments[[link](#environment)]
* Filters support (filter out sensitive or unwanted data that shouldn't be sent) (WIP)[[link](#airbrakeadd_filter)]
* Ability to ignore errors based on any condition (WIP)[[link](#airbrakeadd_filter)]
* SSL support (all communication with Airbrake is encrypted by default)Installation
------------### Cargo
Add the crate to your Cargo.toml:
```toml
[dependencies]
airbrake = "0.2"
```Examples
--------### Basic example
This is the minimal example that you can use to test Airbrake Rust with your
project:```rust
extern crate airbrake;use std::num::ParseIntError;
fn double_number(number_str: &str) -> Result {
number_str.parse::().map(|n| 2 * n)
}fn main() {
let mut airbrake = airbrake::configure(|config| {
config.project_id("113743");
config.project_key("81bbff95d52f8856c770bb39e827f3f6");
});match double_number("NOT A NUMBER") {
Ok(n) => assert_eq!(n, 20),
// Asynchronously sends the error to the dashboard.
Err(err) => {
airbrake.new_notice_builder()
.add_error(err)
.build()
.send();
}
}
}
```Configuration
-------------### project_key & project_id
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.![][project-idkey]
```rust
let mut airbrake = airbrake::configure(|config| {
config.project_id("113743");
config.project_key("81bbff95d52f8856c770bb39e827f3f6");
});
```### host
By default, it is set to `https://app.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).```rust
let mut airbrake = airbrake::configure(|config| {
config.host("http://localhost:8080");
});
```### proxy
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.```rust
let mut airbrake = airbrake::configure(|config| {
config.proxy("127.0.0.1:8080");
});
```### app_version
The version of your application that you can pass to differentiate errors
between multiple versions. It's not set by default.```rust
let mut airbrake = airbrake::configure(|config| {
config.version("1.0.0")
});
```API
---### airbrake
#### airbrake.notify
Sends an error to Airbrake *asynchronously*. `error` must implement the
[`std::error::Error`][stderror] trait. Returns `()`.```rust
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());
```[airbrake.io]: https://airbrake.io
[notice-v3]: https://docs.airbrake.io/docs/#create-notice-v3
[env_logger]: https://crates.io/crates/env_logger
[project-idkey]: https://s3.amazonaws.com/airbrake-github-assets/airbrake-ruby/project-id-key.png
[stderror]: https://doc.rust-lang.org/std/error
[json-object]: https://doc.rust-lang.org/rustc-serialize/rustc_serialize/json/enum.Json.html