userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
solomon.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/utils/statistics/solomon.hpp
4
/// @brief Statistics output in Solomon format.
5
/// @ingroup userver_universal
6
7
#
include
<
string
>
8
#
include
<
unordered_map
>
9
10
#
include
<
userver
/
utils
/
statistics
/
request
.
hpp
>
11
#
include
<
userver
/
utils
/
statistics
/
visit
.
hpp
>
12
13
USERVER_NAMESPACE_BEGIN
14
15
namespace
utils
::
statistics
{
16
17
/// Output `statistics` in Solomon format with tags (labels). It's JSON format
18
/// in the form
19
/// @code
20
21
///{
22
/// "commonLabels": {
23
/// "application": "some-service-name"
24
/// },
25
/// "metrics": [
26
/// {
27
/// "labels": {
28
/// "sensor": "cpu_time_sec"
29
/// },
30
/// "value": 34155.69
31
/// },
32
/// {
33
/// "labels": {
34
/// "sensor": "postgresql.replication-lag.min",
35
/// "postgresql_database": "some_pg_db",
36
/// "postgresql_database_shard": "shard_0",
37
/// "postgresql_cluster_host_type": "slaves",
38
/// "postgresql_instance": "some_host:6432"
39
/// },
40
/// "value": 0
41
/// },
42
/// {
43
/// "labels": {
44
/// "sensor": "http.handler.in-flight",
45
/// "http_path": "/ping",
46
/// "http_handler": "handler-ping"
47
/// },
48
/// "value": 1
49
/// },
50
/// {
51
/// "labels": {
52
/// "sensor": "cache.full.time.last-update-duration-ms",
53
/// "cache_name": "some-cache-name"
54
/// },
55
/// "value": 23
56
/// }
57
/// ]
58
///}
59
60
/// @endcode
61
62
std::string
ToSolomonFormat
(
63
WriterFuncRef
writer,
64
const
std::unordered_map<std::string, std::string>& common_labels,
65
const
Request& statistics_request
=
{
}
66
);
67
68
/// @overload
69
std
::
string
ToSolomonFormat
(
70
const
HasWriterSupport
auto
&
metric
,
71
const
std
::
unordered_map
<
std
::
string
,
std
::
string
>&
common_labels
,
72
const
Request
&
statistics_request
= {}
73
) {
74
return
ToSolomonFormat
([&
metric
](
Writer
&
writer
) {
writer
=
metric
; },
common_labels
,
statistics_request
);
75
}
76
77
}
// namespace utils::statistics
78
79
USERVER_NAMESPACE_END
userver
utils
statistics
solomon.hpp
Generated on
for userver by
Doxygen
1.17.0