[clang-tools-extra] 20f69cc - [clangd] Add a helper for exposing tracer status

Kadir Cetinkaya via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 12 06:27:27 PDT 2020


Author: Kadir Cetinkaya
Date: 2020-10-12T15:25:29+02:00
New Revision: 20f69ccfe64aeab9c32d1698df399bd864dda8b1

URL: https://github.com/llvm/llvm-project/commit/20f69ccfe64aeab9c32d1698df399bd864dda8b1
DIFF: https://github.com/llvm/llvm-project/commit/20f69ccfe64aeab9c32d1698df399bd864dda8b1.diff

LOG: [clangd] Add a helper for exposing tracer status

Added: 
    

Modified: 
    clang-tools-extra/clangd/support/Trace.cpp
    clang-tools-extra/clangd/support/Trace.h

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/support/Trace.cpp b/clang-tools-extra/clangd/support/Trace.cpp
index 89d65e686ebc..d69b1c2bbde5 100644
--- a/clang-tools-extra/clangd/support/Trace.cpp
+++ b/clang-tools-extra/clangd/support/Trace.cpp
@@ -281,6 +281,8 @@ void log(const llvm::Twine &Message) {
   T->instant("Log", llvm::json::Object{{"Message", Message.str()}});
 }
 
+bool enabled() { return T != nullptr; }
+
 // The JSON object is event args (owned by context), if the tracer wants them.
 static std::pair<Context, llvm::json::Object *>
 makeSpanContext(llvm::Twine Name, const Metric &LatencyMetric) {

diff  --git a/clang-tools-extra/clangd/support/Trace.h b/clang-tools-extra/clangd/support/Trace.h
index 7bcfbef7aad2..52ee2ae617da 100644
--- a/clang-tools-extra/clangd/support/Trace.h
+++ b/clang-tools-extra/clangd/support/Trace.h
@@ -128,6 +128,9 @@ std::unique_ptr<EventTracer> createCSVMetricTracer(llvm::raw_ostream &OS);
 /// Records a single instant event, associated with the current thread.
 void log(const llvm::Twine &Name);
 
+/// Returns true if there is an active tracer.
+bool enabled();
+
 /// Records an event whose duration is the lifetime of the Span object.
 /// This lifetime is extended when the span's context is reused.
 ///


        


More information about the cfe-commits mailing list