userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
in_place_span.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/tracing/in_place_span.hpp
4
/// @brief @copybrief tracing::InPlaceSpan
5
6
#
include
<
cstddef
>
7
#
include
<
string
>
8
9
#
include
<
userver
/
compiler
/
select
.
hpp
>
10
#
include
<
userver
/
tracing
/
span
.
hpp
>
11
#
include
<
userver
/
utils
/
fast_pimpl
.
hpp
>
12
13
USERVER_NAMESPACE_BEGIN
14
15
namespace
tracing {
16
17
/// @brief Avoids an extra allocation by storing tracing::Span data in-place
18
/// @warning Never put InPlaceSpan on the stack! It has a large size and can
19
/// cause stack overflow.
20
class
InPlaceSpan
final
{
21
public
:
22
struct
DetachedTag
{};
23
24
explicit
InPlaceSpan(
25
std::string&& name,
26
const
utils
::impl::SourceLocation& source_location =
utils
::impl::SourceLocation::Current()
27
);
28
29
explicit
InPlaceSpan(
30
std::string&& name,
31
std::string_view trace_id,
32
std::string_view parent_span_id,
33
const
utils
::impl::SourceLocation& source_location =
utils
::impl::SourceLocation::Current()
34
);
35
36
explicit
InPlaceSpan(
37
std::string&& name,
38
DetachedTag
,
39
const
utils
::impl::SourceLocation& source_location =
utils
::impl::SourceLocation::Current()
40
);
41
42
InPlaceSpan(InPlaceSpan&&) =
delete
;
43
InPlaceSpan& operator=(InPlaceSpan&&) =
delete
;
44
~InPlaceSpan();
45
46
const
tracing::Span& Get()
const
noexcept
;
47
48
tracing::Span& Get()
noexcept
;
49
50
private
:
51
struct
Impl;
52
53
static
constexpr
std::size_t kImplSize =
compiler
::
SelectSize
().For64Bit(4584).ForLibCpp64(3760).For32Bit(4632);
54
utils
::FastPimpl<Impl, kImplSize, 8> impl_;
55
};
56
57
}
// namespace tracing
58
59
USERVER_NAMESPACE_END
userver
tracing
in_place_span.hpp
Generated on
for userver by
Doxygen
1.17.0