rustsentry

How to set custom fingerprints in the Sentry SDK for Rust?


I would like to set a custom fingerprint for my events using the Sentry SDK for Rust, but I could not find any examples on how to do it.

The official documentation lacks any mention of SDK fingerprinting (unlike the documentation for other platforms). I found a github issue stating that the documentation is missing this bit.

Does anyone have any examples to share?


Solution

  • After some digging, I found this example directly from the sentry-rust repository:

    fn main() {
        let _sentry = sentry::init(sentry::ClientOptions {
            release: sentry::release_name!(),
            debug: true,
            ..Default::default()
        });
        sentry::configure_scope(|scope| {
            scope.set_fingerprint(Some(["my custom fingerprint"].as_ref()));
            scope.set_tag("foo", "bar");
        });
    
        sentry::capture_message("my message", sentry::Level::Warning);
    }
    

    which seems to work in my case.