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
Access handler name #4439
Comments
Would you like to send a PR to expose the handler in It should be good enough to replace the original usage. Note: I though |
As we have an |
The name of the route isn't really an "option" though, is it? It's entirely possible that it should have been: route.info = {
handler,
options
} Which would give |
anyone working on to expose the handler name on the |
I see that you are eager to participate. The issue has to be discussed first. Imho this is a good-first-issue, but until we didnt come to a conclusion, it should not be started. Imho: You can always participate in discussions. By understanding the arguments, providing your own arguments and helping to find a good solution, you will have a greater impact. I also tend to jsumners proposer solution. |
I get what you mean. What about exposing it from |
Yes. fastify.route({
path: '/foo',
method: 'GET',
config: {
// this object is returned by `request.routeConfig`
foo: 'foo'
}
handler
}
async function handler (request, reply) {
return request.routeConfig
} What I'm saying is that we made a mistake in #4216 in naming the new property I'm not sure how others in @fastify/core feel about that though. |
What about request.route? Is that already used? |
Are you referring to #4397? The one you mention(#4216) adds the Is there a strong opinion towards calling it We are in the process of totally deprecating |
🤦♂️ yes.
I think "Info" conveys the same thing, but I don't have a super strong opinion about it. I'll say that "Context" will likely require more explaining about why it is "Context", whereas "Info" is likely self explanatory. |
If we plan to refactor the option inside |
Yes. So @fastify/core should really speak up if they think a new deprecation cycle would be too disruptive. |
Renaming
|
what speaks again request.route ? |
In this case I would be much more in favor of the |
I think |
SGTM 👍 |
It sounds like we are okay with:
{
url,
method,
config, // looks like the current req.routeConfig
schema,
handler // reference to the actual function which would include `handler.name` for named functions
} |
(As suggestion) I would proceed by steps here to ease the review/merge/release:
|
Seems like |
Huston, we have a problem - the docs need to be updated then 😄 from https://www.fastify.io/docs/latest/Reference/Request/#request |
here we can see schema but not handler -> https://www.fastify.io/docs/latest/Reference/Hooks/#onroute this is about the same subject right? routeOptions @Eomm |
I don't think so, This issue refers to the |
Sorry about that, my mistake If so, I think your statement stays true from what I was able to debug |
…-Access-handler-name-add-properties-to-req-route-options
…rties-to-req-route-options
…rties-to-req-route-options
…rties-to-req-route-options
…rties-to-req-route-options
…rties-to-req-route-options
…rties-to-req-route-options
Prerequisites
🚀 Feature Proposal
Open Telemetry accesses the (now deprecated via #4216)
request.context
property so it can try to get the name of the handler function. See https://github.com/open-telemetry/opentelemetry-js-contrib/blob/4cafe6becc19cfb76c53393cb03a5c0574a68b0d/plugins/node/opentelemetry-instrumentation-fastify/src/instrumentation.ts#L264-L268With
request.context
deprecated, we now get a big deprecation warning printed every the app gets its first request. Would it be possible to expose this information in a meaningful way?There's an issue in their repo as well: open-telemetry/opentelemetry-js-contrib#1275
Motivation
It's useful to get the name of a handler function as a span name in traces.
Example
Would replace
request.context.handler.name
The text was updated successfully, but these errors were encountered: