Skip to content

Commit

Permalink
fix fastify deprecated routerMethod、routerPath
Browse files Browse the repository at this point in the history
FastifyDeprecation: You are accessing the deprecated "request.routerMethod" property. Use "request.routeOptions.method" instead. Property "req.routerMethod" will be removed in `fastify@5`.
FastifyDeprecation: You are accessing the deprecated "request.routerPath" property. Use "request.routeOptions.url" instead. Property "req.routerPath" will be removed in `fastify@5`.
  • Loading branch information
xsg-changfuLin committed Dec 15, 2023
1 parent 089bb7a commit ae8437d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/instrumentation/modules/fastify.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ module.exports = function (

agent.logger.debug('adding onRequest hook to fastify');
_fastify.addHook('onRequest', (req, reply, next) => {
const method = req.routerMethod || req.raw.method; // Fallback for fastify >3 <3.3.0
const url = req.routerPath || reply.context.config.url; // Fallback for fastify >3 <3.3.0
const method = req.routeOptions.method || req.raw.method; // Fallback for fastify > 4
const url = req.routeOptions.url || reply.context.config.url; // Fallback for fastify > 4
const name = method + ' ' + url;
agent._instrumentation.setDefaultTransactionName(name);
next();
Expand Down

0 comments on commit ae8437d

Please sign in to comment.