Expand description
§Bugwatch Rust SDK
Official Rust SDK for Bugwatch - AI-Powered Error Tracking.
§Quick Start
use bugwatch::{BugwatchClient, BugwatchOptions, Level};
use std::sync::Arc;
// Create a client
let client = Arc::new(BugwatchClient::new(
BugwatchOptions::new("your-api-key")
.with_environment("production")
.with_release("1.0.0")
));
// Capture an error
if let Err(e) = some_operation() {
client.capture_error(&e);
}
// Capture a message
client.capture_message("Something happened", Level::Warning);§Panic Hook
Install a panic hook to automatically capture panics:
use bugwatch::{BugwatchClient, BugwatchOptions, install_panic_hook};
use std::sync::Arc;
let client = Arc::new(BugwatchClient::new(BugwatchOptions::new("your-api-key")));
install_panic_hook(client);
// Now panics will be captured to Bugwatch§Features
async- Enable async support with tokio (enabled by default)blocking- Enable blocking/sync support (enabled by default)full- Enable all features
§Breadcrumbs
Track user actions leading up to an error:
use bugwatch::{BugwatchClient, BugwatchOptions, Breadcrumb, Level};
let client = BugwatchClient::new(BugwatchOptions::new("your-api-key"));
client.add_breadcrumb(
Breadcrumb::new("http", "GET /api/users")
.with_level(Level::Info)
);§User Context
Associate errors with users:
use bugwatch::{BugwatchClient, BugwatchOptions, UserContext};
let client = BugwatchClient::new(BugwatchOptions::new("your-api-key"));
client.set_user(Some(
UserContext::new()
.with_id("user-123")
.with_email("user@example.com")
));Re-exports§
pub use client::BugwatchClient;pub use env::get_env_options;pub use env::EnvError;pub use fingerprint::fingerprint_from_exception;pub use fingerprint::generate_fingerprint;pub use panic_hook::install_panic_hook;pub use panic_hook::install_panic_hook_with_abort;pub use panic_hook::PanicGuard;pub use transport::ConsoleTransport;pub use transport::HttpTransport;pub use transport::NoopTransport;pub use transport::Transport;pub use transport::TransportError;pub use types::Breadcrumb;pub use types::BugwatchOptions;pub use types::ErrorEvent;pub use types::ExceptionInfo;pub use types::Level;pub use types::RequestContext;pub use types::RuntimeInfo;pub use types::SdkInfo;pub use types::StackFrame;pub use types::UserContext;
Modules§
- backtrace
- Backtrace parsing utilities.
- client
- Bugwatch client for capturing and sending error events.
- env
- Environment variable utilities for Bugwatch Rust SDK.
- fingerprint
- Error fingerprinting for grouping similar errors.
- panic_
hook - Panic hook for automatic panic capture.
- transport
- HTTP transport for sending error events to Bugwatch.
- types
- Type definitions for Bugwatch Rust SDK.
Functions§
- add_
breadcrumb - Add a breadcrumb using the global client.
- capture_
error - Capture an error using the global client.
- capture_
message - Capture a message using the global client.
- close
- Close the global client and release any resources.
- flush
- Flush any pending events using the global client.
- get_
client - Get the global Bugwatch client.
- init
- Initialize the global Bugwatch client.
- init_
from_ env - Initialize the global Bugwatch client from environment variables.
- set_
extra - Set extra context on the global client.
- set_tag
- Set a tag on the global client.
- set_
user - Set user context on the global client.