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

Unable to set transaction name using Nest.js, Apollo GraphQL & @sentry/nestjs #12990

Closed
3 tasks done
nino-vrijman opened this issue Jul 19, 2024 · 7 comments
Closed
3 tasks done

Comments

@nino-vrijman
Copy link

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nestjs

SDK Version

8.19.0

Framework Version

10.3.10

Link to Sentry event

https://nino-vrijman.sentry.io/performance/trace/9dd0463a73c42f414ee79f41e3cf67bd/?node=span-cf85ed63b585ac8f&node=txn-709d8314ffb94ea8a642738416f3efda&project=5585265&query=http.method%3APOST&referrer=performance-transaction-summary&source=performance_transaction_summary&statsPeriod=3m&timestamp=1721399127&transaction=POST+%2Fgraphql&unselectedSeries=p100%28%29&unselectedSeries=avg%28%29

SDK Setup/Reproduction Example

Link to reproduction in a fresh Nest.js project:
https://github.com/nino-vrijman/nest-graphql-sentry-transation-name

// eslint-disable-next-line @typescript-eslint/no-var-requires
const Sentry = require('@sentry/nestjs');

// Ensure to call this before requiring any other modules!
Sentry.init({
  dsn: process.env.SENTRY_DSN,
  sampleRate: 1.0,
  tracesSampleRate: 1.0,
  profilesSampler: 1.0,
  environment: 'localhost',
  integrations: [Sentry.nestIntegration(), Sentry.graphqlIntegration()],
});

Steps to Reproduce

  1. Run back-end using SENTRY_DSN=<your sentry dsn> npm run start:dev
  2. Do a simple GraphQL request with a name of choice: query TestTransactionName { hello }
  3. Check logs that the transaction name seems to have changed in multiple places, most notably in the isolation scope which seems to be the culprit. Only the active span name has been updated.
  4. Check Sentry > Performance and see that every query is grouped under POST /graphql instead of the GraphQL query name like TestTransactionName

Image

Image

Expected Result

The Transaction name on the Performance page is set to GraphQL query TestTransactionName

Actual Result

Everything is grouped under POST /graphql

Image

@andreiborza
Copy link
Member

Hello, thanks for writing in. This is possibly related/a duplicate of #12887. We will check on Monday.

As an aside (and unrelated to this issue), I also noticed you are adding Sentry.nestIntegration. This is no longer required if you're using @sentry/nestjs.

@andreiborza
Copy link
Member

andreiborza commented Jul 31, 2024

@nino-vrijman please check #12887 (comment) and see if this could work for you.

@nino-vrijman
Copy link
Author

@andreiborza
I'm hopefully able to test the linked workaround on this friday or friday next week, I'll get back to you here.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Aug 7, 2024
@andreiborza
Copy link
Member

@nino-vrijman we have a PR for an improvement in the works that should make this a lot easier. You can follow the progress here: #13248.

@nino-vrijman
Copy link
Author

Setting the transaction name as described in this comment in beforeSendTransaction works as expected, thanks for sharing!

I'm curious to see the progress in #13248, ideally it would be possible to set the transaction name in Nest.js' interceptors similar to how I attempted to do it in my reproduction repo and similar to how it worked prior to Sentry v8.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Aug 8, 2024
@andreiborza
Copy link
Member

@nino-vrijman we're planning to release #13248 within this week. As for interceptors, feel free to file a new issue.

@AbhiPrasad
Copy link
Member

Closing this for clean-up. If this issue still applies, please re-open. Thanks!

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

No branches or pull requests

3 participants