autotelic / fastify-opentelemetry

A Fastify plugin that utilizes the OpenTelemetry API to provide request tracing.
MIT License
72 stars 12 forks source link

fix: use request.routeOptions instead of deprecated request.routerPath #60

Closed 10xLaCroixDrinker closed 10 months ago

10xLaCroixDrinker commented 10 months ago

request.routerPath was deprecated in fastify@4.23.0. Since then it produces the following warning:

[FSTDEP017] FastifyDeprecation: You are accessing the deprecated "request.routerPath" property. Use "request.routeOptions.url" instead. Property "req.routerPath" will be removed in `fastify@5`

request.routeOptions was added in fastify@4.10.0. This approach supports backward compatibility while also avoiding accessing request.routerPath in case of a 404 in versions prior to 4.10.0.

Prior to this change, the test suite emitted this warning 11 times. It is now emitted once, only for the new test which covers the case in which request.routeOptions does not exist.

See also open-telemetry/opentelemetry-js-contrib#1757

HW13 commented 10 months ago

Looks like type tests are failing, but that's not related to these changes