-
Notifications
You must be signed in to change notification settings - Fork 1
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
Request metrics question #4
Comments
The plugin is apparently placed after some built-in middlewares (CORS, etc) and before the built-in APIs. I've previously mentioned this on the other thread @ verdaccio/verdaccio#1815 (comment):
So, if one wanted to make the timing metrics more accurate it could make sense to do that handler stack splicing to reorder our handler to the front of the line. There's also the promise of "next major I was planning to add some sort of lifecycle so some actions can be triggered before and after" which would make it a bit cleaner; not sure if/when we'd see that from upstream though. |
Oh sorry i missed that comment, your comment on the original issue. |
No worries. If for your usecase you want the 'most accurate' possible picture of request time, feel free to make a PR to do the splicing hack; something like: // register middleware first, then:
const observer = app._router.stack.pop();
app._router.splice(0, 0, observer); In our usecase here, we mostly want to know that package gets/puts are being processed reasonably well & the default stack order has been working well enough for us since most request time is spent within the API routes. |
verdaccio-openmetrics/src/metrics/requestMetrics.ts
Line 28 in 2a6e18c
@danopia are you sure this will be called before all other middlewares ( build in verdaccio ) ?
last time i checked it wasn't.
I mean if we start timers at the end of request processing will latencies be accurate?
The text was updated successfully, but these errors were encountered: