@@ -5,21 +5,10 @@ import type {
55 ExecutionContext ,
66 HttpServer ,
77 NestInterceptor ,
8- OnModuleInit ,
98} from '@nestjs/common' ;
109import { Catch , Global , HttpException , Injectable , Logger , Module } from '@nestjs/common' ;
1110import { APP_INTERCEPTOR , BaseExceptionFilter } from '@nestjs/core' ;
12- import type { Span } from '@sentry/core' ;
13- import {
14- SEMANTIC_ATTRIBUTE_SENTRY_OP ,
15- SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ,
16- captureException ,
17- getClient ,
18- getDefaultIsolationScope ,
19- getIsolationScope ,
20- logger ,
21- spanToJSON ,
22- } from '@sentry/core' ;
11+ import { captureException , getDefaultIsolationScope , getIsolationScope , logger } from '@sentry/core' ;
2312import type { Observable } from 'rxjs' ;
2413import { isExpectedError } from './helpers' ;
2514
@@ -177,40 +166,6 @@ export { SentryGlobalGraphQLFilter };
177166 */
178167export const SentryGlobalGenericFilter = SentryGlobalFilter ;
179168
180- /**
181- * Service to set up Sentry performance tracing for Nest.js applications.
182- *
183- * @deprecated `SentryService` is deprecated.
184- * If you are using `@sentry/nestjs` you can safely remove any references to the `SentryService`.
185- * If you are using another package migrate to `@sentry/nestjs` and remove the `SentryService` afterwards.
186- */
187- class SentryService implements OnModuleInit {
188- public readonly __SENTRY_INTERNAL__ : boolean ;
189-
190- public constructor ( ) {
191- this . __SENTRY_INTERNAL__ = true ;
192- }
193-
194- /**
195- * Initializes the Sentry service and registers span attributes.
196- */
197- public onModuleInit ( ) : void {
198- // Sadly, NestInstrumentation has no requestHook, so we need to add the attributes here
199- // We register this hook in this method, because if we register it in the integration `setup`,
200- // it would always run even for users that are not even using Nest.js
201- const client = getClient ( ) ;
202- if ( client ) {
203- client . on ( 'spanStart' , span => {
204- addNestSpanAttributes ( span ) ;
205- } ) ;
206- }
207- }
208- }
209- // eslint-disable-next-line deprecation/deprecation
210- Injectable ( ) ( SentryService ) ;
211- // eslint-disable-next-line deprecation/deprecation
212- export { SentryService } ;
213-
214169/**
215170 * Set up a root module that can be injected in nest applications.
216171 */
@@ -222,48 +177,23 @@ class SentryModule {
222177 return {
223178 module : SentryModule ,
224179 providers : [
225- // eslint-disable-next-line deprecation/deprecation
226- SentryService ,
227180 {
228181 provide : APP_INTERCEPTOR ,
229182 // eslint-disable-next-line deprecation/deprecation
230183 useClass : SentryTracingInterceptor ,
231184 } ,
232185 ] ,
233- // eslint-disable-next-line deprecation/deprecation
234- exports : [ SentryService ] ,
235186 } ;
236187 }
237188}
238189Global ( ) ( SentryModule ) ;
239190Module ( {
240191 providers : [
241- // eslint-disable-next-line deprecation/deprecation
242- SentryService ,
243192 {
244193 provide : APP_INTERCEPTOR ,
245194 // eslint-disable-next-line deprecation/deprecation
246195 useClass : SentryTracingInterceptor ,
247196 } ,
248197 ] ,
249- // eslint-disable-next-line deprecation/deprecation
250- exports : [ SentryService ] ,
251198} ) ( SentryModule ) ;
252199export { SentryModule } ;
253-
254- function addNestSpanAttributes ( span : Span ) : void {
255- const attributes = spanToJSON ( span ) . data ;
256-
257- // this is one of: app_creation, request_context, handler
258- const type = attributes [ 'nestjs.type' ] ;
259-
260- // If this is already set, or we have no nest.js span, no need to process again...
261- if ( attributes [ SEMANTIC_ATTRIBUTE_SENTRY_OP ] || ! type ) {
262- return ;
263- }
264-
265- span . setAttributes ( {
266- [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.http.otel.nestjs' ,
267- [ SEMANTIC_ATTRIBUTE_SENTRY_OP ] : `${ type } .nestjs` ,
268- } ) ;
269- }
0 commit comments