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

#include <userver/utils/statistics/storage.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 42 of file storage.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 44 of file storage.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 62 of file storage.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 75 of file storage.hpp.

◆ prefix

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

Return metrics whose path matches with this prefix

Definition at line 59 of file storage.hpp.

◆ prefix_match_type

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

Match type of the prefix

Definition at line 69 of file storage.hpp.

◆ require_labels

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

Require those labels in the metric.

Definition at line 72 of file storage.hpp.


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