From: Teng Qin <qinteng@fb.com>
Date: Wed, 30 Nov 2016 19:07:23 +0000 (-0800)
Subject: Add optional Tracepoint for RequestContext switch
X-Git-Tag: v2016.12.05.00~10
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ea2094274b9d14757595a0677565b011e2b2573d;p=folly.git

Add optional Tracepoint for RequestContext switch

Summary: Using newly added `StaticTracepoint.h`, add a Tracepoint for `RequestContext` switch that could be enabled by compiler flag.

Reviewed By: drarmstr

Differential Revision: D4238658

fbshipit-source-id: 043a035ba8251b48d7b29d63a2219ad2edda164f
---

diff --git a/folly/Makefile.am b/folly/Makefile.am
index 768fdf6f..6aea6dd1 100644
--- a/folly/Makefile.am
+++ b/folly/Makefile.am
@@ -363,6 +363,7 @@ nobase_follyinclude_HEADERS = \
 	ThreadName.h \
 	TimeoutQueue.h \
 	TokenBucket.h \
+	tracing/StaticTracepoint.h \
 	Traits.h \
 	Try-inl.h \
 	Try.h \
diff --git a/folly/io/async/Request.cpp b/folly/io/async/Request.cpp
index 3babeea6..1c9e071c 100644
--- a/folly/io/async/Request.cpp
+++ b/folly/io/async/Request.cpp
@@ -20,6 +20,7 @@
  */
 
 #include <folly/io/async/Request.h>
+#include <folly/tracing/StaticTracepoint.h>
 
 #include <glog/logging.h>
 
@@ -94,6 +95,7 @@ std::shared_ptr<RequestContext> RequestContext::setContext(
     std::shared_ptr<RequestContext> ctx) {
   auto& curCtx = getStaticContext();
   if (ctx != curCtx) {
+    FOLLY_SDT(folly, request_context_switch_before, curCtx.get(), ctx.get());
     using std::swap;
     if (curCtx) {
       curCtx->onUnset();