clang-tools 20.0.0git
Public Types | Public Member Functions | Public Attributes | List of all members
clang::clangd::trace::Metric Struct Reference

Represents measurements of clangd events, e.g. More...

#include <Trace.h>

Public Types

enum  MetricType { Value , Counter , Distribution }
 

Public Member Functions

constexpr Metric (llvm::StringLiteral Name, MetricType Type, llvm::StringLiteral LabelName=llvm::StringLiteral(""))
 
void record (double Value, llvm::StringRef Label="") const
 Records a measurement for this metric to active tracer.
 

Public Attributes

const llvm::StringLiteral Name
 Uniquely identifies the metric.
 
const MetricType Type
 
const llvm::StringLiteral LabelName
 Indicates what measurement labels represent, e.g.
 

Detailed Description

Represents measurements of clangd events, e.g.

operation latency. Those measurements are recorded per-label, defaulting to an empty one for metrics that don't care about it. This enables aggregation of measurements across labels. For example a metric tracking accesses to a cache can have labels named hit and miss.

Definition at line 38 of file Trace.h.

Member Enumeration Documentation

◆ MetricType

Enumerator
Value 

A number whose value is meaningful, and may vary over time.

Each measurement replaces the current value.

Counter 

An aggregate number whose rate of change over time is meaningful.

Each measurement is an increment for the counter.

Distribution 

A distribution of values with a meaningful mean and count.

Each measured value is a sample for the distribution. The distribution is assumed not to vary, samples are aggregated over time.

Definition at line 39 of file Trace.h.

Constructor & Destructor Documentation

◆ Metric()

constexpr clang::clangd::trace::Metric::Metric ( llvm::StringLiteral  Name,
MetricType  Type,
llvm::StringLiteral  LabelName = llvm::StringLiteral("") 
)
inlineconstexpr

Definition at line 54 of file Trace.h.

Member Function Documentation

◆ record()

void clang::clangd::trace::Metric::record ( double  Value,
llvm::StringRef  Label = "" 
) const

Records a measurement for this metric to active tracer.

Definition at line 329 of file Trace.cpp.

References clang::clangd::Label, LabelName, and Value.

Referenced by clang::clangd::ClangdServer::applyTweak(), clang::clangd::getHover(), clang::clangd::rename(), and clang::clangd::ClangdServer::rename().

Member Data Documentation

◆ LabelName

const llvm::StringLiteral clang::clangd::trace::Metric::LabelName

Indicates what measurement labels represent, e.g.

"operation_name" for a metric tracking latencies. If non empty all measurements must also have a non-empty label.

Definition at line 68 of file Trace.h.

Referenced by record().

◆ Name

const llvm::StringLiteral clang::clangd::trace::Metric::Name

Uniquely identifies the metric.

Should use snake_case identifiers, can use dots for hierarchy if needed. e.g. method_latency, foo.bar.

Definition at line 63 of file Trace.h.

Referenced by clang::clangd::trace::TestTracer::record().

◆ Type

const MetricType clang::clangd::trace::Metric::Type

Definition at line 64 of file Trace.h.


The documentation for this struct was generated from the following files: