Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

nicohrubec
Copy link
Contributor

@nicohrubec nicohrubec commented Aug 1, 2024

Adds automatic instrumentation of interceptors to @sentry/nestjs. Interceptors in nest have a @Injectable decorator and implement a intercept function. So we can simply extend the existing instrumentation to add a proxy for intercept.

Current screenshot from my sample app:
Screenshot 2024-08-01 at 13 29 20

Remark: Interceptors allow users to add functionality before and after a route handler is called. This PR adds tracing to whatever happens before the route is executed. I am still figuring out how to trace any instructions after the route was executed. Will do that in a separate PR.

Copy link
Contributor

github-actions bot commented Aug 1, 2024

size-limit report 📦

Path Size
@sentry/browser 22.45 KB (0%)
@sentry/browser (incl. Tracing) 34.22 KB (0%)
@sentry/browser (incl. Tracing, Replay) 70.28 KB (0%)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 63.62 KB (0%)
@sentry/browser (incl. Tracing, Replay with Canvas) 74.68 KB (0%)
@sentry/browser (incl. Tracing, Replay, Feedback) 87.26 KB (0%)
@sentry/browser (incl. Tracing, Replay, Feedback, metrics) 89.11 KB (0%)
@sentry/browser (incl. metrics) 26.75 KB (0%)
@sentry/browser (incl. Feedback) 39.37 KB (0%)
@sentry/browser (incl. sendFeedback) 27.06 KB (0%)
@sentry/browser (incl. FeedbackAsync) 31.7 KB (0%)
@sentry/react 25.22 KB (0%)
@sentry/react (incl. Tracing) 37.22 KB (0%)
@sentry/vue 26.6 KB (0%)
@sentry/vue (incl. Tracing) 36.06 KB (0%)
@sentry/svelte 22.58 KB (0%)
CDN Bundle 23.64 KB (0%)
CDN Bundle (incl. Tracing) 35.88 KB (0%)
CDN Bundle (incl. Tracing, Replay) 70.31 KB (0%)
CDN Bundle (incl. Tracing, Replay, Feedback) 75.57 KB (0%)
CDN Bundle - uncompressed 69.37 KB (0%)
CDN Bundle (incl. Tracing) - uncompressed 106.31 KB (0%)
CDN Bundle (incl. Tracing, Replay) - uncompressed 218.16 KB (0%)
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 230.99 KB (0%)
@sentry/nextjs (client) 37.07 KB (0%)
@sentry/sveltekit (client) 34.79 KB (0%)
@sentry/node 114.77 KB (+0.09% 🔺)
@sentry/node - without tracing 89.33 KB (0%)
@sentry/aws-serverless 98.5 KB (0%)

@nicohrubec nicohrubec marked this pull request as ready for review August 1, 2024 14:03
@nicohrubec nicohrubec requested review from lforst and chargome August 1, 2024 14:07

const transactionEvent = await pageloadTransactionEventPromise;

console.log(transactionEvent.spans);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log(transactionEvent.spans);


const transactionEvent = await pageloadTransactionEventPromise;

console.log(transactionEvent.spans);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log(transactionEvent.spans);

* Interceptor to add Sentry tracing capabilities to Nest.js applications.
*/
class SentryTracingInterceptor implements NestInterceptor {
public static readonly __SENTRY_INTERNAL__ = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l: maybe add a comment for this one

Copy link
Member

@chargome chargome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@nicohrubec nicohrubec changed the title feat(nestjs): Automatic instrumentation of nestjs interceptors feat(nestjs): Automatic instrumentation of nestjs interceptors before route execution Aug 1, 2024
@nicohrubec nicohrubec merged commit 964d050 into develop Aug 2, 2024
@nicohrubec nicohrubec deleted the nh/instrument-nest-interceptors branch August 2, 2024 07:24
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

Successfully merging this pull request may close these issues.

2 participants