clang-tools  14.0.0git
Classes | Functions
clang::clangd::trace Namespace Reference

Classes

class  EventTracer
 A consumer of trace events and measurements. More...
 
struct  Metric
 Represents measurements of clangd events, e.g. More...
 
class  Session
 Sets up a global EventTracer that consumes events produced by Span and trace::log. More...
 
class  Span
 Records an event whose duration is the lifetime of the Span object. More...
 
class  TestTracer
 A RAII Tracer that can be used by tests. More...
 

Functions

std::unique_ptr< EventTracercreateJSONTracer (llvm::raw_ostream &OS, bool Pretty=false)
 Create an instance of EventTracer that produces an output in the Trace Event format supported by Chrome's trace viewer (chrome://tracing). More...
 
std::unique_ptr< EventTracercreateCSVMetricTracer (llvm::raw_ostream &OS)
 Create an instance of EventTracer that outputs metric measurements as CSV. More...
 
void log (const llvm::Twine &Name)
 Records a single instant event, associated with the current thread. More...
 
bool enabled ()
 Returns true if there is an active tracer. More...
 
static std::pair< Context, llvm::json::Object * > makeSpanContext (llvm::Twine Name, const Metric &LatencyMetric)
 
constexpr Metric SpanLatency ("span_latency", Metric::Distribution, "span_name")
 

Function Documentation

◆ createCSVMetricTracer()

std::unique_ptr< EventTracer > clang::clangd::trace::createCSVMetricTracer ( llvm::raw_ostream &  OS)

Create an instance of EventTracer that outputs metric measurements as CSV.

Trace spans and instant events are ignored.

Definition at line 274 of file Trace.cpp.

References OS.

◆ createJSONTracer()

std::unique_ptr< EventTracer > clang::clangd::trace::createJSONTracer ( llvm::raw_ostream &  OS,
bool  Pretty = false 
)

Create an instance of EventTracer that produces an output in the Trace Event format supported by Chrome's trace viewer (chrome://tracing).

FIXME: Metrics are not recorded, some could become counter events.

The format is documented here: https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview

Definition at line 269 of file Trace.cpp.

◆ enabled()

bool clang::clangd::trace::enabled ( )

Returns true if there is an active tracer.

Definition at line 284 of file Trace.cpp.

◆ log()

void clang::clangd::trace::log ( const llvm::Twine &  Message)

Records a single instant event, associated with the current thread.

Definition at line 278 of file Trace.cpp.

References clang::tidy::bugprone::Message.

◆ makeSpanContext()

static std::pair<Context, llvm::json::Object *> clang::clangd::trace::makeSpanContext ( llvm::Twine  Name,
const Metric LatencyMetric 
)
static

Definition at line 288 of file Trace.cpp.

◆ SpanLatency()

constexpr Metric clang::clangd::trace::SpanLatency ( "span_latency"  ,
Metric::Distribution  ,
"span_name"   
)
constexpr