@@ -5,21 +5,10 @@ import type {
5
5
ExecutionContext ,
6
6
HttpServer ,
7
7
NestInterceptor ,
8
- OnModuleInit ,
9
8
} from '@nestjs/common' ;
10
9
import { Catch , Global , HttpException , Injectable , Logger , Module } from '@nestjs/common' ;
11
10
import { 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' ;
23
12
import type { Observable } from 'rxjs' ;
24
13
import { isExpectedError } from './helpers' ;
25
14
@@ -177,40 +166,6 @@ export { SentryGlobalGraphQLFilter };
177
166
*/
178
167
export const SentryGlobalGenericFilter = SentryGlobalFilter ;
179
168
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
-
214
169
/**
215
170
* Set up a root module that can be injected in nest applications.
216
171
*/
@@ -222,48 +177,23 @@ class SentryModule {
222
177
return {
223
178
module : SentryModule ,
224
179
providers : [
225
- // eslint-disable-next-line deprecation/deprecation
226
- SentryService ,
227
180
{
228
181
provide : APP_INTERCEPTOR ,
229
182
// eslint-disable-next-line deprecation/deprecation
230
183
useClass : SentryTracingInterceptor ,
231
184
} ,
232
185
] ,
233
- // eslint-disable-next-line deprecation/deprecation
234
- exports : [ SentryService ] ,
235
186
} ;
236
187
}
237
188
}
238
189
Global ( ) ( SentryModule ) ;
239
190
Module ( {
240
191
providers : [
241
- // eslint-disable-next-line deprecation/deprecation
242
- SentryService ,
243
192
{
244
193
provide : APP_INTERCEPTOR ,
245
194
// eslint-disable-next-line deprecation/deprecation
246
195
useClass : SentryTracingInterceptor ,
247
196
} ,
248
197
] ,
249
- // eslint-disable-next-line deprecation/deprecation
250
- exports : [ SentryService ] ,
251
198
} ) ( SentryModule ) ;
252
199
export { 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