userver: userver/utils/statistics/prometheus.hpp Source File
⚠️ This is the documentation for an old userver version. Click here to switch to the latest version.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
prometheus.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/utils/statistics/prometheus.hpp
4/// @brief Statistics output in Prometheus format.
5
6#include <string>
7
8#include <userver/utils/statistics/storage.hpp>
9
10USERVER_NAMESPACE_BEGIN
11
12namespace utils::statistics {
13
14namespace impl {
15
16// The metric name specifies the general feature of a system that is measured
17// (e.g. http_requests_total - the total number of HTTP requests received).
18// It may contain ASCII letters and digits, as well as underscores and colons.
19// It must match the regex [a-zA-Z_][a-zA-Z0-9_]*.
20std::string ToPrometheusName(std::string_view data);
21
22// Label names may contain ASCII letters, numbers, as well as underscores.
23// They must match the regex [a-zA-Z_][a-zA-Z0-9_]*.
24// Label names beginning with __ are reserved for internal use.
25std::string ToPrometheusLabel(std::string_view name);
26
27} // namespace impl
28
29/// Output `statistics` in Prometheus format, each metric has `gauge` type.
30std::string ToPrometheusFormat(const utils::statistics::Storage& statistics,
31 const utils::statistics::Request& request = {});
32
33/// Output `statistics` in Prometheus format, without metric types.
35 const utils::statistics::Storage& statistics,
36 const utils::statistics::Request& request = {});
37
38} // namespace utils::statistics
39
40USERVER_NAMESPACE_END