Backend: Error Monitoring
Go
Java
JS
Python
Ruby
Rust
Backend: Logging
Go
JS
Python
Ruby
Java
Rust
Hosting Providers
Backend: Tracing
Go
Node.js
Python
Rust
Native OpenTelemetry
Fullstack Frameworks
Overview
Self Host & Local Dev
Menu
Using highlight.io without a framework in Rust
Learn how to set up highlight.io without a framework.
1
Install the Highlight Rust SDK.
Add Highlight to your Config.toml. You'll need to pick your features based on what kind of runtime your project uses. If everything is synchronous, you can use the default features. If you're using tokio
, turn off default features and use the feature tokio
. If you're using async-std
, turn off default features and use the feature async-std
.
[dependencies.highlightio]
version = "1"
default-features = ...
features = [...]
2
Initialize the Highlight Rust SDK.
highlightio::Highlight::init
initializes the SDK.
use highlightio::{Highlight, HighlightConfig};
// or async fn main()
// with #[tokio::main] if you're using tokio, etc.
fn main() {
let h = Highlight::init(HighlightConfig {
project_id: "<YOUR_PROJECT_ID>".to_string(),
service_name: "my-rust-app".to_string(),
service_version: "git-sha".to_string(),
..Default::default()
}).expect("Failed to initialize Highlight.io");
// ...
h.shutdown();
}
3
Capture errors.
Highlight::capture_error
can be used to explicitly capture any error.
fn do_something() -> Result<(), Error> {
// ...
}
fn main() {
// ...
match do_something() {
Ok(_) => {},
Err(e) => h.capture_error(&e),
};
}
4
Verify your errors are being recorded.
Now that you've set up the SDK, you can verify that the backend error handling works by sending an error in. Visit the highlight errors page and check that backend errors are coming in.
fn main() {
// ...
let e = std::io::Error::new(
std::io::ErrorKind::Other,
"This is a test error."
);
h.capture_error(&e);
}
5
Set up logging.
Start sending logs to Highlight! Follow the logging setup guide to get started.