Skip to main content

Crate exceptionless

Crate exceptionless 

Source
Expand description

§Exceptionless client for Rust

exceptionless is an async Rust client for the current Exceptionless MVP slice: error reporting, log events, and feature usage tracking.

§Supported today

  • Error events with captured stack frames and inner error chaining
  • Log events with optional source, level, tags, user identity, version, and custom data
  • Feature usage events with tags, user identity, version, and custom data
  • Direct async submission to POST /api/v2/events
  • Default hosted collector or a custom self-hosted Exceptionless server
  • Custom transports through the transport::Transport trait

§Not yet supported

  • Automatic queueing, offline storage, or retry workers
  • Server-side settings/config synchronization
  • Session tracking
  • Plugin hooks
  • Logging facade integrations

§Quick start

use exceptionless::ExceptionlessClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = ExceptionlessClient::with_api_key("YOUR_API_KEY");

    let result = client
        .log("worker started")
        .source("jobs")
        .level("info")
        .tag("startup")
        .send()
        .await?;

    if !result.response.is_success() {
        eprintln!("submission was not accepted: {:?}", result.action);
    }

    Ok(())
}

§Common event builders

use core::num::ParseIntError;
use exceptionless::ExceptionlessClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = ExceptionlessClient::with_api_key("YOUR_API_KEY");

    let parse_error: ParseIntError = "not a number".parse::<i32>().unwrap_err();
    client
        .error(&parse_error)
        .tag("parsing")
        .source("user_input")
        .data("raw_value", "not a number")
        .send()
        .await?;

    client
        .feature("export_to_pdf")
        .user_identity("user@example.com")
        .version("1.2.3")
        .send()
        .await?;

    Ok(())
}

§Custom server configuration

use exceptionless::ExceptionlessClient;
use exceptionless::config::ClientConfig;
use exceptionless::transport::http::HttpTransport;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = ClientConfig::new("YOUR_API_KEY")
        .with_server_url("https://your-exceptionless-server.com");

    let client = ExceptionlessClient::new(config, HttpTransport::default());
    client.log("self-hosted ready").send().await?;
    Ok(())
}

Disabling a config::ClientConfig with config::ClientConfig::with_enabled causes submission to fail before the transport is invoked.

Re-exports§

pub use client::ExceptionlessClient;
pub use error::ClientError;
pub use error::ErrorEventBuilder;
pub use feature::FeatureUsageBuilder;
pub use log::LogEventBuilder;

Modules§

builder
client
config
error
event
feature
log
transport
wire