userver: utils::statistics::Request Class Reference
Loading...
Searching...
No Matches
utils::statistics::Request Class Referencefinal

#include <userver/utils/statistics/request.hpp>

Detailed Description

Class describing the request for metrics data.

Metric path and metric name are the same thing. For example for code like

writer["a"]["b"]["c"] = 42;

the metric name is "a.b.c" and in Prometheus format it would be escaped like "a_b_c{} 42".

Note
add_labels should not match labels from Storage, otherwise the returned metrics may not be read by metrics server.

Definition at line 30 of file request.hpp.

Public Types

enum class  PrefixMatch {
  kNoop ,
  kExact ,
  kStartsWith
}
 Enum for different match types of the prefix More...
 
using AddLabels = std::unordered_map< std::string, std::string >
 

Public Member Functions

 Request ()=default
 

Static Public Member Functions

static Request MakeWithPrefix (const std::string &prefix, AddLabels add_labels={}, std::vector< Label > require_labels={})
 Makes request for metrics whose path starts with the prefix.
 
static Request MakeWithPath (const std::string &path, AddLabels add_labels={}, std::vector< Label > require_labels={})
 Makes request for metrics whose path is path.
 

Public Attributes

const std::string prefix {}
 Return metrics whose path matches with this prefix
 
const PrefixMatch prefix_match_type = PrefixMatch::kNoop
 Match type of the prefix
 
const std::vector< Labelrequire_labels {}
 Require those labels in the metric.
 
const AddLabels add_labels {}
 Add those labels to each returned metric.
 

Member Typedef Documentation

◆ AddLabels

using utils::statistics::Request::AddLabels = std::unordered_map<std::string, std::string>

Definition at line 32 of file request.hpp.

Member Enumeration Documentation

◆ PrefixMatch

Enum for different match types of the prefix

Enumerator
kNoop 

Do not match, the prefix is empty.

kExact 

prefix equal to path

kStartsWith 

Metric path starts with prefix

Definition at line 56 of file request.hpp.

Constructor & Destructor Documentation

◆ Request()

utils::statistics::Request::Request ( )
default

Default request without parameters. Equivalent to requesting all the metrics without adding or requiring any labels.

Member Data Documentation

◆ add_labels

const AddLabels utils::statistics::Request::add_labels {}

Add those labels to each returned metric.

Definition at line 69 of file request.hpp.

◆ prefix

const std::string utils::statistics::Request::prefix {}

Return metrics whose path matches with this prefix

Definition at line 53 of file request.hpp.

◆ prefix_match_type

const PrefixMatch utils::statistics::Request::prefix_match_type = PrefixMatch::kNoop

Match type of the prefix

Definition at line 63 of file request.hpp.

◆ require_labels

const std::vector<Label> utils::statistics::Request::require_labels {}

Require those labels in the metric.

Definition at line 66 of file request.hpp.


The documentation for this class was generated from the following file: