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

Scope::set_user does not affect users reported in performance transactions #648

Open
antifuchs opened this issue Apr 1, 2024 · 3 comments

Comments

@antifuchs
Copy link

antifuchs commented Apr 1, 2024

Environment

I'm instrumenting an axum web app, using the default set of tower middleware, tags / user fields set using sentry::configure_scope land on error reporting events, but they are missing from Performance transactions.

Steps to Reproduce

  1. Set up the default sentry_tower layers:

         .layer(sentry_tower::NewSentryLayer::new_from_top())
         .layer(sentry_tower::SentryHttpLayer::with_transaction())
  2. In a handler (or another layer, it doesn't matter) sets user information or tags on the scope using the (docs-recommended) method, like:

      sentry::configure_scope(|scope| {
          scope.set_tag("lz_transaction", "woo weeee");
          scope.set_user(Some(User {
              id: Some(user.id.id().to_string()),
              username: Some(user.name.to_owned()),
              ..Default::default()
          }));
      });
  1. Call up a normally-succeeding handler
  2. Put panic!("oops"); in that handler to get an error event.

Expected Result

I'd like the transactions list in Performance to list Users and other tags, like sentry does in error events.

Actual Result

The error event has a user set, but the performance transaction doesn't.

The error event has the user:
image

perf monitoring list:
image

@szokeasaurusrex szokeasaurusrex self-assigned this Apr 5, 2024
@Swatinem
Copy link
Member

Swatinem commented Apr 5, 2024

This should have been implemented a long time ago in #596. It might be possible that the transaction is not using the correct Hub/Scope, or the problem might be elsewhere.

@antifuchs
Copy link
Author

Oh, I forgot to mention: using scope.set_transaction to name the transaction does make it to the performance list; but the rest of the data associated with the scope doesn't. (I did remove that set_transaction call when writing my tests, thinking it would help; it didn't...)

@ollipa
Copy link

ollipa commented May 6, 2024

I had a similar issue. I was setting the user in a spawned task. When I spawned the task, I was calling .bind_hub(Hub::new_from_top(Hub::current())) on it. After changing it to .bind_hub(Hub::current()) I could see user in performance traces.

I thought that creating a new Hub would also work and using the current Hub would not be required.

@szokeasaurusrex szokeasaurusrex removed their assignment May 31, 2024
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

4 participants