-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(node/nestjs): Use method on current fastify request (#15066)
The previous code was using fastify `request.routeOptions.method` which is all methods the current route supports - not the current request method. Ex. `@All()` nestjs decorator `request.routeOptions.method = ['GET', 'POST', 'HEAD', ...]` - Added a test for `@All()` - Updated instances of fastify request to use `request.method` which matches express --------- Co-authored-by: Charly Gomez <[email protected]>
- Loading branch information
Showing
5 changed files
with
16 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,10 +25,10 @@ interface Fastify { | |
* Works for Fastify 3, 4 and presumably 5. | ||
*/ | ||
interface FastifyRequestRouteInfo { | ||
method?: string; | ||
// since [email protected] | ||
routeOptions?: { | ||
url?: string; | ||
method?: string; | ||
}; | ||
routerPath?: string; | ||
} | ||
|
@@ -107,7 +107,7 @@ export function setupFastifyErrorHandler(fastify: Fastify): void { | |
// Taken from Otel Fastify instrumentation: | ||
// https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts#L94-L96 | ||
const routeName = reqWithRouteInfo.routeOptions?.url || reqWithRouteInfo.routerPath; | ||
const method = reqWithRouteInfo.routeOptions?.method || 'GET'; | ||
const method = reqWithRouteInfo.method || 'GET'; | ||
|
||
getIsolationScope().setTransactionName(`${method} ${routeName}`); | ||
}); | ||
|