Skip to content

Transaction is not finished if panic occurs within it #753

@lcian

Description

@lcian

Steps to Reproduce

Run the following example:

use axum::routing;
use axum::{extract::Request, Router};
use tower;

async fn handler() -> String {
    let parent_span = sentry::configure_scope(|scope| scope.get_span());
    if let Some(sentry::TransactionOrSpan::Transaction(tx)) = parent_span {
        let span = tx.start_child("span operation", "span description");
        span.finish();
    }
    panic!("oh no");
}

#[tokio::main]
async fn main() {
    let _guard = sentry::init((
        "https://6b76fb2a5dc1164849cd797b75b6d879@o447951.ingest.us.sentry.io/4508694563782656",
        sentry::ClientOptions {
            release: sentry::release_name!(),
            traces_sample_rate: 1.0,
            debug: true,
            ..Default::default()
        },
    ));

    let app = Router::new().route("/", routing::get(handler)).layer(
        tower::ServiceBuilder::new()
            .layer(sentry_tower::NewSentryLayer::<Request>::new_from_top())
            .layer(sentry_tower::SentryHttpLayer::with_transaction()),
    );

    let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
    axum::serve(listener, app).await.unwrap();
}

Expected Result

  • The "GET /" transaction and the manually created span are captured
  • The trace and transaction are marked as errored, the transaction associated with the issue corresponding to the panic

Example from Python
Image

Actual Result

Only the panic is reported, with a fake trace ("Missing Trace Spans")

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions