Add a timestamp to the Rook request object.#262
Open
atheriel wants to merge 1 commit intorstudio:mainfrom
Open
Add a timestamp to the Rook request object.#262atheriel wants to merge 1 commit intorstudio:mainfrom
atheriel wants to merge 1 commit intorstudio:mainfrom
Conversation
Contributor
Author
|
CI failures seem unrelated. |
Collaborator
|
The CI failures are due to RcppCore/Rcpp#1048. |
Requests objects now have a `httpuv.timestamp` member containing a timestamp compatible with Sys.time(). This timestamp is captured when the request is received at the C++ level in the background thread, which has two advantages: 1. We can much more accurately capture the total time the client actually waits for the request to get processed. 2. We can instrument the time it takes before the R-level callback actually runs. More broadly, the timestamp makes it easier to log measures of request latency in httpuv-based applications, and reduces the overhead of common ways to do so -- e.g. using Plumber hooks. Signed-off-by: Aaron Jacobs <aaron.jacobs@crescendotechnology.com>
b16a5f4 to
a24c919
Compare
Contributor
Author
|
Tweaked slightly and rebased to fix merge conflicts. |
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds a
httpuv.timestampmember containing a timestamp compatible withSys.time()to the Rook request object. You can use these timestamps it to measure and report on request latency:Importantly, this timestamp is captured when the request is received at the C++ level in the background thread, which has two advantages:
We can much more accurately capture the total time the client actually waits for the request to get processed, especially if the R thread is congested or running GC.
We can instrument the time it takes before the R-level callback actually runs.
More broadly, the timestamp makes it easier to log measures of request latency in
httpuv-based applications, and reduces the overhead of common ways to do so -- e.g. using Plumber hooks.I'm unsure about whether
httpuv.timestampis a good name, and am happy to take suggestions for improvements.Also, I have little faith in my C++ (though I've made sure to use C++11-compatible interfaces here).
Finally, if you're interested in R's internal
Sys.time()implementation, the source is intime.c:currentTime().