@@ -15,7 +15,7 @@ let updateRetryData
1515
1616/**
1717 * Keep track of endpoints that still need to be sent.
18- * Map key is `${METHOD} ${PATH}`, value is { method, path }
18+ * Map key is `${METHOD} ${PATH}`, value is { method, path, operationName }
1919 */
2020const pendingEndpoints = new Map ( )
2121const wildcardEndpoints = new Set ( )
@@ -32,11 +32,11 @@ function scheduleFlush () {
3232 setImmediate ( flushAndSend ) . unref ( )
3333}
3434
35- function recordEndpoint ( method , path ) {
35+ function recordEndpoint ( method , path , operationName ) {
3636 const key = endpointKey ( method , path )
3737 if ( pendingEndpoints . has ( key ) ) return
3838
39- pendingEndpoints . set ( key , { method : method . toUpperCase ( ) , path } )
39+ pendingEndpoints . set ( key , { method : method . toUpperCase ( ) , path, operationName } )
4040 scheduleFlush ( )
4141}
4242
@@ -46,7 +46,7 @@ function onFastifyRoute (routeData) {
4646
4747 const methods = Array . isArray ( routeOptions . method ) ? routeOptions . method : [ routeOptions . method ]
4848 for ( const method of methods ) {
49- recordEndpoint ( method , routeOptions . path )
49+ recordEndpoint ( method , routeOptions . path , 'fastify.request' )
5050 }
5151}
5252
@@ -56,7 +56,7 @@ function onExpressRoute ({ method, path }) {
5656 // If wildcard already recorded for this path, skip specific methods
5757 if ( wildcardEndpoints . has ( path ) ) return
5858
59- recordEndpoint ( method , path )
59+ recordEndpoint ( method , path , 'express.request' )
6060
6161 // If this is a wildcard event, record it and mark path as wildcarded
6262 if ( method === '*' ) {
@@ -66,17 +66,17 @@ function onExpressRoute ({ method, path }) {
6666
6767 // Express automatically adds HEAD support for GET routes
6868 if ( method . toUpperCase ( ) === 'GET' ) {
69- recordEndpoint ( 'HEAD' , path )
69+ recordEndpoint ( 'HEAD' , path , 'express.request' )
7070 }
7171}
7272
7373function buildEndpointObjects ( endpoints ) {
74- return endpoints . map ( ( { method, path } ) => {
74+ return endpoints . map ( ( { method, path, operationName } ) => {
7575 return {
7676 type : 'REST' ,
7777 method,
7878 path,
79- operation_name : 'http.request' ,
79+ operation_name : operationName ,
8080 resource_name : endpointKey ( method , path )
8181 }
8282 } )
0 commit comments