userver: userver/utils/statistics/solomon.hpp Source File
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
6#include <string>
7
8#include <userver/utils/statistics/storage.hpp>
9
10USERVER_NAMESPACE_BEGIN
11
12namespace utils::statistics {
13
14/// Output `statistics` in Solomon format with tags (labels). It's JSON format
15/// in the form
16/// @code
17
18///{
19/// "commonLabels": {
20/// "application": "some-service-name"
21/// },
22/// "metrics": [
23/// {
24/// "labels": {
25/// "sensor": "cpu_time_sec"
26/// },
27/// "value": 34155.69
28/// },
29/// {
30/// "labels": {
31/// "sensor": "postgresql.replication-lag.min",
32/// "postgresql_database": "some_pg_db",
33/// "postgresql_database_shard": "shard_0",
34/// "postgresql_cluster_host_type": "slaves",
35/// "postgresql_instance": "some_host:6432"
36/// },
37/// "value": 0
38/// },
39/// {
40/// "labels": {
41/// "sensor": "http.handler.in-flight",
42/// "http_path": "/ping",
43/// "http_handler": "handler-ping"
44/// },
45/// "value": 1
46/// },
47/// {
48/// "labels": {
49/// "sensor": "cache.full.time.last-update-duration-ms",
50/// "cache_name": "some-cache-name"
51/// },
52/// "value": 23
53/// }
54/// ]
55///}
56
57/// @endcode
58
59std::string ToSolomonFormat(
60 const utils::statistics::Storage& statistics,
61 const std::unordered_map<std::string, std::string>& common_labels,
62 const utils::statistics::Request& statistics_request = {});
63
64} // namespace utils::statistics
65
66USERVER_NAMESPACE_END