userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
client_metrics_shard.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/server/request/client_metrics_shard.hpp
4
/// @brief @copybrief server::request::SetClientMetricsShard
5
6
#
include
<
optional
>
7
#
include
<
string_view
>
8
9
#
include
<
userver
/
server
/
request
/
impl
/
client_metrics_shard
.
hpp
>
10
#
include
<
userver
/
utils
/
statistics
/
labels
.
hpp
>
11
12
USERVER_NAMESPACE_BEGIN
13
14
namespace
server::
request
{
15
16
/// @brief Set the client metrics shard (path + labels) for requests
17
/// performed by the current task and its child tasks.
18
///
19
/// When set, supporting clients additionally accumulate their metrics on a new
20
/// subpath with the provided labels. It is a client-side counterpart of
21
/// @ref server::request::RequestContext::SetHandlerMetricsShard.
22
///
23
/// The setting lives until the end of the current task and is inherited by
24
/// child tasks.
25
///
26
/// Supported by:
27
/// * HTTP client: `timings`, `errors` and `reply-statuses` destination metrics
28
/// are accumulated on `httpclient.<path>.*` with the `http_destination` label
29
/// and the provided labels. Requests without destination metrics (e.g. when
30
/// `destination-metrics-auto-max-size` of http-client-core is reached)
31
/// are not accounted in the shard.
32
///
33
/// @note Labels should be lexicographically sorted by name and must not
34
/// contain `http_destination` and `version`.
35
/// @see ClientMetricsShardScope
36
void
SetClientMetricsShard
(std::string_view path,
utils
::
statistics
::LabelsSpan labels);
37
38
/// @brief Remove the client metrics shard set by @ref SetClientMetricsShard
39
/// for requests performed by the current task and its child tasks.
40
void
EraseClientMetricsShard
()
noexcept
;
41
42
/// @brief Sets the client metrics shard (see @ref SetClientMetricsShard)
43
/// within its scope and restores the previous one on destruction.
44
class
[[nodiscard]] ClientMetricsShardScope
final
{
45
public
:
46
ClientMetricsShardScope(std::string_view path,
utils
::
statistics
::LabelsSpan labels);
47
48
ClientMetricsShardScope(ClientMetricsShardScope&&) =
delete
;
49
ClientMetricsShardScope& operator=(ClientMetricsShardScope&&) =
delete
;
50
~ClientMetricsShardScope();
51
52
private
:
53
std::optional<impl::ClientMetricsShard> old_value_;
54
};
55
56
}
// namespace server::request
57
58
USERVER_NAMESPACE_END
userver
server
request
client_metrics_shard.hpp
Generated on
for userver by
Doxygen
1.17.0