Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues and trace not working #683

Open
ghmendonca opened this issue Sep 14, 2024 · 0 comments
Open

Issues and trace not working #683

ghmendonca opened this issue Sep 14, 2024 · 0 comments

Comments

@ghmendonca
Copy link

I'm trying to configure sentry for my application and doesn't seem to work. I've read all the issues related and I couldn't find a single example to make this work.

My application is very small, I have just 2 endpoints, and one of them is just a health check. The other one is an endpoint to process images, it downloads files from s3, process them and then uploads back to s3. The tracing is working because I can see a bunch of logs, but it's not being sent to sentry.

Here is my code:

fn main() {
    let _ = sentry::init((
        "***",
        sentry::ClientOptions {
            release: sentry::release_name!(),
            traces_sample_rate: 0.2,
            environment: Some(
                std::env::var("STAGE")
                    .unwrap_or(String::from("local"))
                    .into(),
            ),
            ..Default::default()
        },
    ));

    tokio::runtime::Builder::new_multi_thread()
        .enable_all()
        .build()
        .unwrap()
        .block_on(async {
            tracing_subscriber::registry()
                .with(tracing_subscriber::fmt::layer())
                .with(sentry_tracing::layer())
                .init();

            dotenv().ok();

            let config = load_defaults(BehaviorVersion::latest())
                .await
                .to_builder()
                .stalled_stream_protection(StalledStreamProtectionConfig::disabled())
                .build();
            let client = aws_sdk_s3::Client::new(&config);
            let aws = AWSService::new(client);

            let state = AppState { aws };

            let app = Router::new()
                .route("/images", post(process_images))
                .route("/health", get(health))
                .layer(sentry_tower::NewSentryLayer::new_from_top())
                .layer(sentry_tower::SentryHttpLayer::with_transaction())
                .with_state(state);

            let stage = std::env::var("STAGE");

            if stage.is_ok() && stage.unwrap() == String::from("local") {
                let listener = TcpListener::bind("0.0.0.0:8080").await?;

                println!("Server started on {}", listener.local_addr()?);

                serve(listener, app).await?;

                return Ok(());
            } else {
                return run(app).await;
            }
        })
        .unwrap();
}

This is not working local or when I deploy. Not sure if makes any difference, but I'm deploying my application to AWS Lambda using the serverless framework.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant