-
Notifications
You must be signed in to change notification settings - Fork 518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FastifyDeprecation warning for accessing request.routerPath
when accessing a non-existing page
#1757
Comments
See #1757 (comment) |
I'll cut a release that includes #1679 and we can see if this is fixed. Seems to me that it shoudl be. |
@dyladan That says it was released 3 weeks ago. Was it not? |
Sorry I didn't confirm before typing that. @Wazbat can you confirm your issue is fixed? Seems we didn't catch all uses of deprecated properties then |
@dyladan I can take this. I was just looking at it. |
I think the issue is that on 404 pages, neither |
I'm using the following packages and versions: {
"@autotelic/fastify-opentelemetry": "^0.17.1",
"@opentelemetry/instrumentation": "^0.44.0",
"@opentelemetry/instrumentation-fastify": "^0.32.3",
"@opentelemetry/instrumentation-http": "^0.44.0",
"@opentelemetry/resources": "^1.17.1",
"@opentelemetry/sdk-trace-node": "^1.17.0",
"fastify": "^4.24.3",
} And simplified app is as follows import Fastify from 'fastify';
import openTelemertryPlugin from '@autotelic/fastify-opentelemetry';
const fastify = Fastify();
await fastify.register(openTelemertryPlugin, {
wrapRoutes: ['/my/route']
});
fastify.post('/my/route', async (req, res) =>{
const { activeSpan } = req.openTelemetry();
activeSpan?.setAttributes({ key: 'value' });
res.send('whatever');
}); When running my application with this, I'm seeing these logs
|
@Wazbat it's the |
I'd prefer not to have different logic to try to sniff if the new attributes are the appropriate ones to use. I saw some reference about undefined values for a Fastify error as well. My suspicion is that cases other than a 404 might have an empty
Currently I'm adding a 404 test case and there is a separate weirdness. The const handlerName = handler?.name.substr(6); There it is assuming a handler is of the form |
…ion warning for 404 request For a 404 `request.routeOptions.url` is undefined. Since fastify@4.10.0 when routeOptions was added, we shouldn't fallback to the deprecated request.routerPath. This also corrects the assumption that the handler name is "bound ..." in all cases. E.g. for a 404 it is Fastify's core "basic404" internal function. Fixes: open-telemetry#1757
Ah thanks for clarifying! |
@Wazbat I'll open a PR to autotelic/fastify-opentelemetry |
Thank you! That'd be awesome. My workaround for now is as follows, should anyone find this through google: await fastify.register(openTelemertryPlugin, {
wrapRoutes: ['/v3/search/merchant'],
formatSpanName: (req) => (req.routeOptions?.url ? `${req.method} ${req.routeOptions.url}` : req.method)
}); Looks like this GH issue is unrelated, please disregard my comments about it occuring on existing routes |
… FastifyDeprecation warning for 404 request (#1763) For a 404 `request.routeOptions.url` is undefined. Since fastify@4.10.0 when routeOptions was added, we shouldn't fallback to the deprecated request.routerPath. This also corrects the assumption that the handler name is "bound ..." in all cases. E.g. for a 404 it is Fastify's core "basic404" internal function. Also add a test that Fastify instrumentation works for ESM usage. Fixes: #1757 Co-authored-by: Marc Pichler <marc.pichler@dynatrace.com>
@trentm does that fix apply only to non-existing routes/pages? |
@Fernandomr88 With that commit, the instrumentation-fastify will no longer access |
Separating the issue reported here #1275 (comment)
What version of OpenTelemetry are you using?
@opentelemetry/instrumentation-fastify@032.3
What version of Node are you using?
v18
What did you do?
Instrumented node with fastify instrumentation, did a request to a non-existing page.
Can be reproduced by starting the fastify example and doing a request to any non-existent page
What did you expect to see?
No deprecation notices
What did you see instead?
Additional context
We are using the latest version of the intrumentation
https://github.com/dailydotdev/daily-api/blob/dc3bbecd7c04984a60a224b19ae9752102caf09e/package.json#L48
and version 4.24.2 of fastify
https://github.com/dailydotdev/daily-api/blob/dc3bbecd7c04984a60a224b19ae9752102caf09e/package.json#L71
So digging a bit further into it, I think it might when the requests are to not found pages. but then both
request.routeOptions.url
andrequest.routerPath
are undefined.The text was updated successfully, but these errors were encountered: