userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
tag_scope.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/tracing/tag_scope.hpp
4
/// @brief @copybrief tracing::TagScope
5
6
#
include
<
string
>
7
#
include
<
vector
>
8
9
#
include
<
userver
/
logging
/
log_extra
.
hpp
>
10
#
include
<
userver
/
tracing
/
span
.
hpp
>
11
12
USERVER_NAMESPACE_BEGIN
13
14
namespace
tracing
{
15
16
/// @brief RAII object that calls Span::AddTag / Span::AddTagFrozen function
17
/// in constructor and reverts these actions in destructor.
18
///
19
/// ## Example usage:
20
/// @snippet tracing/tag_scope_test.cpp TagScope - sample
21
class
TagScope
{
22
public
:
23
explicit
TagScope(
24
std::string key,
25
logging::LogExtra::Value value,
26
logging::LogExtra::
ExtendType
extend_type = logging
::
LogExtra
::
ExtendType
::
kNormal
27
);
28
29
explicit
TagScope(
30
Span& parent,
31
std::string key,
32
logging::LogExtra::Value value,
33
logging::LogExtra::
ExtendType
extend_type = logging
::
LogExtra
::
ExtendType
::
kNormal
34
);
35
36
explicit
TagScope(logging::LogExtra&& extra);
37
38
explicit
TagScope(Span& parent, logging::LogExtra&& extra);
39
40
~TagScope();
41
42
TagScope(
const
TagScope
& other) =
delete
;
43
TagScope
& operator=(
const
TagScope
& other) =
delete
;
44
45
TagScope(
TagScope
&& other) =
delete
;
46
TagScope
& operator=(
TagScope
&& other) =
delete
;
47
48
private
:
49
void
AddTag(std::string&& key, logging::LogExtra::ProtectedValue&& value);
50
51
static
constexpr
std::size_t kNewKeysVectorSize = 8;
52
53
Span& parent_;
54
std::size_t new_tags_begin_index_;
55
std::size_t new_tags_end_index_;
56
std::vector<std::pair<std::size_t, logging::LogExtra::ProtectedValue>> previous_values_;
57
};
58
59
}
// namespace tracing
60
61
USERVER_NAMESPACE_END
userver
tracing
tag_scope.hpp
Generated on
for userver by
Doxygen
1.17.0