Automatic Instrumentation

tracing Integration

The Rust SDK offers an integration for the tracing ecosystem that will track spans automatically for every function that is annotated with #[tracing::instrument].

The integration takes care of starting a new transaction or a new child span of an already running transaction, and it automatically sets the created span as the current span.

fn main() {

    let _sentry = sentry::init(sentry::ClientOptions {
        release: sentry::release_name!(),
        traces_sample_rate: 1.0,


fn main_span1() {


fn main_span2() {

HTTP Instrumentation

The Sentry SDK offers an integration for the tower ecosystem which can automatically continue a trace from an incoming HTTP request.

use sentry_tower::{NewSentryLayer, SentryHttpLayer};
use tower::ServiceBuilder;

let layer = ServiceBuilder::new()
    // continue trace from incoming request
    // bind a new hub for each request
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) to suggesting an update ("yeah, this would be better").
Suggest an edit to this page   |  Contribute to Docs   |  

Report a Problem

🎉 Thank you for your feedback! 🙌
Report a problem