-
-
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 interceptors after …
…route execution (#13264) Adding a span 'Interceptor - After Span' to improve instrumentation for operations happening after the route execution is done. Tracking what happens in individual interceptors after the route is hard, so currently we create one span to trace everything that happens after the route is executed.
- Loading branch information
1 parent
b192678
commit 7e9a038
Showing
14 changed files
with
794 additions
and
68 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
17 changes: 17 additions & 0 deletions
17
dev-packages/e2e-tests/test-applications/nestjs-basic/src/async-example.interceptor.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,17 @@ | ||
import { CallHandler, ExecutionContext, Injectable, NestInterceptor } from '@nestjs/common'; | ||
import * as Sentry from '@sentry/nestjs'; | ||
import { tap } from 'rxjs'; | ||
|
||
@Injectable() | ||
export class AsyncInterceptor implements NestInterceptor { | ||
intercept(context: ExecutionContext, next: CallHandler) { | ||
Sentry.startSpan({ name: 'test-async-interceptor-span' }, () => {}); | ||
return Promise.resolve( | ||
next.handle().pipe( | ||
tap(() => { | ||
Sentry.startSpan({ name: 'test-async-interceptor-span-after-route' }, () => {}); | ||
}), | ||
), | ||
); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
dev-packages/e2e-tests/test-applications/nestjs-basic/src/example-1.interceptor.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,15 @@ | ||
import { CallHandler, ExecutionContext, Injectable, NestInterceptor } from '@nestjs/common'; | ||
import * as Sentry from '@sentry/nestjs'; | ||
import { tap } from 'rxjs'; | ||
|
||
@Injectable() | ||
export class ExampleInterceptor1 implements NestInterceptor { | ||
intercept(context: ExecutionContext, next: CallHandler) { | ||
Sentry.startSpan({ name: 'test-interceptor-span-1' }, () => {}); | ||
return next.handle().pipe( | ||
tap(() => { | ||
Sentry.startSpan({ name: 'test-interceptor-span-after-route' }, () => {}); | ||
}), | ||
); | ||
} | ||
} |
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
Oops, something went wrong.