-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Implement post-response hook for logging and monitoring, including matched route and params #3840
Comments
Thinking about it more, I don't think we need |
This was referenced Feb 11, 2022
See related discussion of param validators here: #4291 |
5 tasks
Rich-Harris
added a commit
that referenced
this issue
Mar 16, 2022
5 tasks
Rich-Harris
added a commit
that referenced
this issue
Mar 16, 2022
* expose event.routeKey - closes #3840 * change routeKey to routeId * rename routeKey to routeId, expose page.routeId * rename route.key -> route.id everywhere * adapter-node sure picked a weird time to stop typechecking * oops * Update .changeset/mean-crews-unite.md
Thanks @Rich-Harris 😄 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the problem
I've split this out from #1194 (comment), which is a slightly different issue and request.
I'm keen to implement good logging and monitoring for my SvelteKit app. For monitoring, in particular, it's extremely useful to know which route, and which params, produced the final response. I use Prometheus, and with my old Express.js app I'd typically label each finished request/response with details like
{method: 'GET', route: '/users/[id]/details', status: 200}
. This generic route parameter means that I can aggregate all similar requests to the same route and understand how long the responses took to generate on average (or stddev, etc). At present, since I don't know which route rendered the response inhandle()
, the best I can do is to useurl.pathname
, which means I can't aggregate across similar request to the same route.Describe the proposed solution
Perhaps we could consider a
handleResponse
hook, with a signature something like this (and apologies, my TypeScript knowledge is almost nil, so this is pseudocode-typing!):I could make use of details from the
route
object (ideally, I'd get the path of the.svelte
or.js
file which finally served the response, or something else akin to the Express route (e.g.'/users/[id]/details'
). I'd also log the response duration, and I might make use ofparams
in my logging output.Alternatives considered
At the moment, I don't believe it's possible to determine which route/params combo produced the response which
resolve()
fromhooks.handle()
returns, so I don't think I can get this data without a code change.Importance
i cannot use SvelteKit without it
Additional Information
Something along these lines will be vital to people running SvelteKit apps in production, IMO.
The text was updated successfully, but these errors were encountered: