clang-tools 19.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).
 
std::unique_ptr< EventTracercreateCSVMetricTracer (llvm::raw_ostream &OS)
 Create an instance of EventTracer that outputs metric measurements as CSV.
 
void log (const llvm::Twine &Name)
 Records a single instant event, associated with the current thread.
 
bool enabled ()
 Returns true if there is an active tracer.
 
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 273 of file Trace.cpp.

References OS.

Referenced by clang::clangd::clangdMain().

◆ 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 268 of file Trace.cpp.

References OS.

Referenced by clang::clangd::clangdMain(), and main().

◆ enabled()

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

Returns true if there is an active tracer.

Definition at line 283 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 277 of file Trace.cpp.

Referenced by clang::clangd::StreamLogger::log().

◆ makeSpanContext()

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

Definition at line 287 of file Trace.cpp.

References Args, clang::clangd::Context::current(), and Name.

◆ SpanLatency()

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