-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nestjs): Automatic instrumentation of nestjs guards (#13129)
Adds automatic instrumentation to `@sentry/nestjs`. Guards in nest have a `@Injectable` decorator and implement a `canActivate` function. So we can simply extend the existing instrumentation to add a proxy for `canActivate`. Also fixed a mistake with the middleware instrumentation (missing return).
- Loading branch information
1 parent
4972604
commit e2668f8
Showing
7 changed files
with
207 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
dev-packages/e2e-tests/test-applications/nestjs-basic/src/example.guard.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common'; | ||
import * as Sentry from '@sentry/nestjs'; | ||
|
||
@Injectable() | ||
export class ExampleGuard implements CanActivate { | ||
canActivate(context: ExecutionContext): boolean { | ||
Sentry.startSpan({ name: 'test-guard-span' }, () => {}); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
dev-packages/e2e-tests/test-applications/node-nestjs-basic/src/example.guard.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common'; | ||
import * as Sentry from '@sentry/nestjs'; | ||
|
||
@Injectable() | ||
export class ExampleGuard implements CanActivate { | ||
canActivate(context: ExecutionContext): boolean { | ||
Sentry.startSpan({ name: 'test-guard-span' }, () => {}); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters