Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { Controller, Get, Param, ParseIntPipe, UseFilters, UseGuards, UseInterceptors } from '@nestjs/common';
import { flush } from '@sentry/nestjs';
import { AppService } from './app.service';
import { AsyncInterceptor } from './async-example.interceptor';
import { ExampleInterceptor1 } from './example-1.interceptor';
import { ExampleInterceptor2 } from './example-2.interceptor';
import { ExampleExceptionGlobalFilter } from './example-global-filter.exception';
import { ExampleExceptionLocalFilter } from './example-local-filter.exception';
import { ExampleLocalFilter } from './example-local.filter';
import { ExampleGuard } from './example.guard';
import { ExampleInterceptor } from './example.interceptor';

@Controller()
@UseFilters(ExampleLocalFilter)
Expand All @@ -29,11 +31,17 @@ export class AppController {
}

@Get('test-interceptor-instrumentation')
@UseInterceptors(ExampleInterceptor)
@UseInterceptors(ExampleInterceptor1, ExampleInterceptor2)
testInterceptorInstrumentation() {
return this.appService.testSpan();
}

@Get('test-async-interceptor-instrumentation')
@UseInterceptors(AsyncInterceptor)
testAsyncInterceptorInstrumentation() {
return this.appService.testSpan();
}

@Get('test-pipe-instrumentation/:id')
testPipeInstrumentation(@Param('id', ParseIntPipe) id: number) {
return { value: id };
Expand Down
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' }, () => {});
}),
),
);
}
}
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' }, () => {});
}),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { CallHandler, ExecutionContext, Injectable, NestInterceptor } from '@nes
import * as Sentry from '@sentry/nestjs';

@Injectable()
export class ExampleInterceptor implements NestInterceptor {
export class ExampleInterceptor2 implements NestInterceptor {
intercept(context: ExecutionContext, next: CallHandler) {
Sentry.startSpan({ name: 'test-interceptor-span' }, () => {});
Sentry.startSpan({ name: 'test-interceptor-span-2' }, () => {});
return next.handle().pipe();
}
}
Loading
Loading