clang-tools  12.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>

Collaboration diagram for clang::clangd::trace::Metric:
Collaboration graph
[legend]

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. More...
 

Public Attributes

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

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("") 
)
inline

Definition at line 54 of file Trace.h.

References record(), and Value.

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

Referenced by Metric().

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.

◆ 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: