@@ -27,7 +27,7 @@ import {
2727} from '@opentelemetry/instrumentation' ;
2828import { ATTR_HTTP_ROUTE } from '@opentelemetry/semantic-conventions' ;
2929import type { SpanAttributes } from '@sentry/core' ;
30- import { SDK_VERSION , startSpan } from '@sentry/core' ;
30+ import { SDK_VERSION , SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN , startSpan } from '@sentry/core' ;
3131import { AttributeNames , NestType } from './enums' ;
3232
3333const PACKAGE_NAME = '@sentry/instrumentation-nestjs-core' ;
@@ -137,8 +137,10 @@ function createWrapNestFactoryCreate(moduleVersion?: string) {
137137 return startSpan (
138138 {
139139 name : 'Create Nest App' ,
140+ op : `${ NestType . APP_CREATION } .nestjs` ,
140141 attributes : {
141142 ...NestInstrumentation . COMMON_ATTRIBUTES ,
143+ [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.http.otel.nestjs' ,
142144 [ AttributeNames . TYPE ] : NestType . APP_CREATION ,
143145 [ AttributeNames . VERSION ] : moduleVersion ,
144146 [ AttributeNames . MODULE ] : nestModule . name ,
@@ -165,6 +167,7 @@ function createWrapCreateHandler(moduleVersion: string | undefined) {
165167 const req = handlerArgs [ 0 ] as NestRequest ;
166168 const attributes : SpanAttributes = {
167169 ...NestInstrumentation . COMMON_ATTRIBUTES ,
170+ [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.http.otel.nestjs' ,
168171 [ AttributeNames . VERSION ] : moduleVersion ,
169172 [ AttributeNames . TYPE ] : NestType . REQUEST_CONTEXT ,
170173 [ ATTR_HTTP_ROUTE ] : req . route ?. path || req . routeOptions ?. url || req . routerPath ,
@@ -173,7 +176,9 @@ function createWrapCreateHandler(moduleVersion: string | undefined) {
173176 } ;
174177 attributes [ 'http.method' ] = req . method ;
175178 attributes [ 'http.url' ] = req . originalUrl || req . url ;
176- return startSpan ( { name : spanName , attributes } , ( ) => handler . apply ( this , handlerArgs ) ) ;
179+ return startSpan ( { name : spanName , op : `${ NestType . REQUEST_CONTEXT } .nestjs` , attributes } , ( ) =>
180+ handler . apply ( this , handlerArgs ) ,
181+ ) ;
177182 } ;
178183 } ;
179184 } ;
@@ -183,12 +188,15 @@ function createWrapHandler(moduleVersion: string | undefined, handler: AnyFn): A
183188 const spanName = handler . name || 'anonymous nest handler' ;
184189 const attributes : SpanAttributes = {
185190 ...NestInstrumentation . COMMON_ATTRIBUTES ,
191+ [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.http.otel.nestjs' ,
186192 [ AttributeNames . VERSION ] : moduleVersion ,
187193 [ AttributeNames . TYPE ] : NestType . REQUEST_HANDLER ,
188194 [ AttributeNames . CALLBACK ] : handler . name ,
189195 } ;
190196 const wrappedHandler = function ( this : unknown , ...args : unknown [ ] ) {
191- return startSpan ( { name : spanName , attributes } , ( ) => handler . apply ( this , args ) ) ;
197+ return startSpan ( { name : spanName , op : `${ NestType . REQUEST_HANDLER } .nestjs` , attributes } , ( ) =>
198+ handler . apply ( this , args ) ,
199+ ) ;
192200 } ;
193201
194202 if ( handler . name ) {
0 commit comments