Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ref(nestjs): Add mechanism to captured errors #17312

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

Merged
Lms24 merged 3 commits into develop from lms/ref-nestjs-mechanism
Sep 5, 2025
Merged

Conversation

Copy link
Member

@Lms24 Lms24 commented Aug 4, 2025
edited
Loading

The NestJS SDK didn't add a mechanism to a bunch of caught errors. This resulted in the errors being incorrectly marked as handled: true and the mechansim.type defaulting to 'generic'.

This PR:

  • adds the mechanism to all captureException calls within the SDK, marking caught exceptions as handled: false
    • reviewers: Please let me know if any of these should in fact be handled: true!
  • adds a specific mechanism.type, following the naming scheme of trace origin
  • adjusts and adds test assertions so that we actually test on the expected mechanism

I noticed that we have some startSpan calls in the SDK that don't include a sentry.origin attribute. I'll open a follow-up PR to fix this separately.

ref #17212
closes #17259

@Lms24 Lms24 marked this pull request as draft August 4, 2025 15:24
@@ -19,12 +19,12 @@ export const SentryCron = (monitorSlug: string, monitorConfig?: MonitorConfig):
try {
result = originalMethod.apply(this, args);
} catch (e) {
captureException(e);
captureException(e, { mechanism: { handled: false, type: 'auto.cron.nestjs' } });
Copy link
Member Author

@Lms24 Lms24 Aug 5, 2025
edited
Loading

Choose a reason for hiding this comment

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

(auto.)cron is not a listed category, which is a bit suboptimal. The two alternatives are:

  • function given we wrap some kind of cron-executed function
  • omitting the category, since it's not required: auto.nestjs.sentry_cron

@AbhiPrasad thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

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

worth noting: I didn't find a specific span that reliably applies here, so there's no direct span counterpart to this mechanism.type

Copy link
Member

@AbhiPrasad AbhiPrasad Aug 5, 2025

Choose a reason for hiding this comment

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

let's do auto.function.X

Lms24 reacted with thumbs up emoji
@@ -77,7 +77,7 @@ export function SentryExceptionCaptured() {
return originalCatch.apply(this, [exception, host, ...args]);
}

captureException(exception);
captureException(exception, { mechanism: { handled: false, type: 'auto.function.nestjs.exception_captured' } });
Copy link
Member Author

Choose a reason for hiding this comment

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

I think auto.function.* is correct here, given this decorator can be applied to any arbitrary function.

chargome reacted with thumbs up emoji
@Lms24 Lms24 self-assigned this Aug 5, 2025
@Lms24 Lms24 marked this pull request as ready for review August 5, 2025 08:36
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.

Looks good, thanks!

@Lms24 Lms24 force-pushed the lms/ref-nestjs-mechanism branch from 638238a to a99673b Compare September 5, 2025 14:08
@Lms24 Lms24 merged commit af69b45 into develop Sep 5, 2025
163 checks passed
@Lms24 Lms24 deleted the lms/ref-nestjs-mechanism branch September 5, 2025 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@chargome chargome chargome approved these changes

@AbhiPrasad AbhiPrasad Awaiting requested review from AbhiPrasad

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Adjust mechanism in nestjs SDK

AltStyle によって変換されたページ (->オリジナル) /