userver: userver/utils/statistics/json.hpp Source File
Loading...
Searching...
No Matches
json.hpp
Go to the documentation of this file.
1#pragma once
2
3/// @file userver/utils/statistics/json.hpp
4/// @brief Statistics output in JSON format.
5/// @ingroup userver_universal
6
7#include <string>
8
9#include <userver/utils/statistics/request.hpp>
10#include <userver/utils/statistics/visit.hpp>
11
12USERVER_NAMESPACE_BEGIN
13
14namespace utils::statistics {
15
16/// Output `statistics` in JSON format:
17/// @code
18/// {
19/// "metric-path": [
20/// {
21/// "type": "GAUGE",
22/// "value": 42,
23/// "labels": {
24/// "some-label": "label-value",
25/// "some-other-label": "other-label-value",
26/// }
27/// },
28/// {
29/// "type": "RATE",
30/// "value": 43,
31/// "labels": {
32/// "another-label": "another-value"
33/// }
34/// },
35/// ]
36/// }
37/// @endcode
38///
39/// @note An integer `GAUGE` and a floating-point `GAUGE` are both written as a JSON number
40/// of the same type. In practice they cannot be told apart.
41/// @note A histogram writes only @ref utils::statistics::HistogramView::GetTotalSum into `sum`.
42/// Sums of individual buckets are not written.
43std::string ToJsonFormat(WriterFuncRef writer, const Request& statistics_request = {});
44
45/// @overload
49
50} // namespace utils::statistics
51
52USERVER_NAMESPACE_END