Go to the documentation of this file.
17 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_SUPPORT_TRACE_H
18 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SUPPORT_TRACE_H
21 #include "llvm/ADT/StringRef.h"
22 #include "llvm/ADT/Twine.h"
23 #include "llvm/Support/JSON.h"
24 #include "llvm/Support/raw_ostream.h"
55 llvm::StringLiteral
LabelName = llvm::StringLiteral(
""))
63 const llvm::StringLiteral
Name;
88 llvm::function_ref<
void(llvm::json::Object *)> AttachDetails);
101 llvm::StringRef
Label) {}
121 bool Pretty =
false);
129 void log(
const llvm::Twine &
Name);
154 llvm::json::Object *
const Args;
158 Span(std::pair<Context, llvm::json::Object *>);
164 #define SPAN_ATTACH(S, Name, Expr) \
166 if (auto *Args = (S).Args) \
167 (*Args)[Name] = Expr; \
const llvm::StringLiteral LabelName
Indicates what measurement labels represent, e.g.
A consumer of trace events and measurements.
std::unique_ptr< trace::EventTracer > Tracer
virtual void instant(llvm::StringRef Name, llvm::json::Object &&Args)
Called for instant events.
void record(double Value, llvm::StringRef Label="") const
Records a measurement for this metric to active tracer.
const llvm::StringLiteral Name
Uniquely identifies the metric.
virtual void record(const Metric &Metric, double Value, llvm::StringRef Label)
Called whenever a metrics records a measurement.
void log(const llvm::Twine &Message)
Records a single instant event, associated with the current thread.
std::unique_ptr< EventTracer > createJSONTracer(llvm::raw_ostream &OS, bool Pretty)
Create an instance of EventTracer that produces an output in the Trace Event format supported by Chro...
std::unique_ptr< EventTracer > createCSVMetricTracer(llvm::raw_ostream &OS)
Create an instance of EventTracer that outputs metric measurements as CSV.
bool enabled()
Returns true if there is an active tracer.
llvm::json::Object *const Args
Mutable metadata, if this span is interested.
@ Distribution
A distribution of values with a meaningful mean and count.
WithContext replaces Context::current() with a provided scope.
Session(EventTracer &Tracer)
Sets up a global EventTracer that consumes events produced by Span and trace::log.
virtual ~EventTracer()=default
@ Counter
An aggregate number whose rate of change over time is meaningful.
Represents measurements of clangd events, e.g.
virtual Context beginSpan(llvm::StringRef Name, llvm::function_ref< void(llvm::json::Object *)> AttachDetails)
Called when event that has a duration starts.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
llvm::raw_string_ostream OS
constexpr Metric(llvm::StringLiteral Name, MetricType Type, llvm::StringLiteral LabelName=llvm::StringLiteral(""))
@ Value
A number whose value is meaningful, and may vary over time.
A context is an immutable container for per-request data that must be propagated through layers that ...
Records an event whose duration is the lifetime of the Span object.