userver: userver/utils/statistics/prometheus.hpp Source File
Loading...
Searching...
No Matches
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/// @ingroup userver_universal
6
7#include <string>
8#include <string_view>
9
10#include <userver/utils/statistics/request.hpp>
11#include <userver/utils/statistics/visit.hpp>
12
13USERVER_NAMESPACE_BEGIN
14
15namespace utils::statistics {
16
17namespace impl {
18
19// The metric name specifies the general feature of a system that is measured
20// (e.g. http_requests_total - the total number of HTTP requests received).
21// It may contain ASCII letters and digits, as well as underscores and colons.
22// It must match the regex [a-zA-Z_][a-zA-Z0-9_]*.
23std::string ToPrometheusName(std::string_view data);
24
25// Label names may contain ASCII letters, numbers, as well as underscores.
26// They must match the regex [a-zA-Z_][a-zA-Z0-9_]*.
27// Label names beginning with __ are reserved for internal use.
28std::string ToPrometheusLabel(std::string_view name);
29
30} // namespace impl
31
32/// Output `statistics` in Prometheus format, each metric has `gauge` type.
33std::string ToPrometheusFormat(WriterFuncRef writer, const Request& request = {});
34
35/// @overload
39
40/// Output `statistics` in Prometheus format, without metric types.
41std::string ToPrometheusFormatUntyped(WriterFuncRef writer, const Request& request = {});
42
43/// @overload
47
48} // namespace utils::statistics
49
50USERVER_NAMESPACE_END