Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
Thank you for this Hapi extension! I find it very useful and it helps me to monitor my microservices.
Recently I discovered a possible bug or strange behaviour. The response times displayed on the status page do not correspond with any other response times measured by other means like developer tools in a browser or good-console logging.
It displays constantly times under 1ms, which is already strange. Especially, when all other tools display response times around 1.5s for my requests.
First, there were a computation flaw in the formula
((diff[0] * 1e3) + diff[1]) * 1e-6
=>((sec * 1e3 + nanos) * 1e-6
=>(ms + nanos) * 1e-6
. Basically a flaw in groupping of the parts.When I fixed that, I discovered that the start time is recorded too late, when the computation in routes is already finished, in the
onPreResponse
hook. So the time diff doesn't say anything about the processing time. But there is arequest.info.received
variable from Hapi, which marks the request start and we can compute the diff against it.After that correction, the response time displays realistic values. The presentation has to be adapted slightly and do not display decimal values, but this is just a design issue.
Could you please check my changes and consider to merge them? Thank you!
It would be even possible to simplify the middleware-wrapper.js to something like:
to get even more precise response times, but this would need some additional refactoring.