API to set folly::RequestContext for current scope
Summary:There're currently two ways to set RequestContext
- RequestContext::create() - creates new context and sets it
- RequestContext::setContext(context) - sets context previously captured by saveContext
In most cases, the RequestContext is set back after the request is processed but sometimes it's not (especially with RequestContext::create). We want to measure cpu time for a request by measuring the total cpu time when a RequestContext is set, so we need to make sure that it's properly reset after the thread is done with the request. Scope guards can help us with that.
Reviewed By: haijunz
Differential Revision:
D3156698
fb-gh-sync-id:
cfb678531810e8be5faaf02cb7803bd247557e42
fbshipit-source-id:
cfb678531810e8be5faaf02cb7803bd247557e42