macro to enable scoped trace section functionality
authorAlison Tsai <alisontsai@fb.com>
Wed, 23 Aug 2017 23:50:28 +0000 (16:50 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 24 Aug 2017 00:13:18 +0000 (17:13 -0700)
Summary: Add a macro to enable optional scoped trace section functionality (user-defined). This macro will have no effect unless configured to do so. This change means that if proxygen is being upgraded, folly must also be updated.

Reviewed By: mzlee

Differential Revision: D5635123

fbshipit-source-id: 7db17f6ae8c0d1484cf9fad043eb42717279bd0a

folly/Makefile.am
folly/tracing/ScopedTraceSection.h [new file with mode: 0644]

index 40f9d7fdff8116a93ed4134e32e6889c88a6abbb..d2ed843eb41a63c8e2dee6d31675f4fb9729bd73 100644 (file)
@@ -428,6 +428,7 @@ nobase_follyinclude_HEADERS = \
        TimeoutQueue.h \
        TokenBucket.h \
        tracing/StaticTracepoint.h \
+       tracing/ScopedTraceSection.h \
        Traits.h \
        Try-inl.h \
        Try.h \
diff --git a/folly/tracing/ScopedTraceSection.h b/folly/tracing/ScopedTraceSection.h
new file mode 100644 (file)
index 0000000..07aa77c
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2017-present Facebook, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * This macro enables FbSystrace usage in production for fb4a. When
+ * FOLLY_SCOPED_TRACE_SECTION_HEADER is defined then a trace section is started
+ * and later automatically terminated at the close of the scope it is called in.
+ * In all other cases no action is taken.
+ */
+
+#pragma once
+
+#if defined(FOLLY_SCOPED_TRACE_SECTION_HEADER)
+#include FOLLY_SCOPED_TRACE_SECTION_HEADER
+#else
+#define FOLLY_SCOPED_TRACE_SECTION(arg, ...) \
+  do {                                       \
+  } while (0)
+#endif