blob: 05815c1e38ee63ad3b1f2d9047f0a050344aa592 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
#pragma once
#include <library/cpp/yt/global/access.h>
#include <library/cpp/yt/memory/ref.h>
#include <library/cpp/yt/misc/guid.h>
#include <library/cpp/yt/misc/thread_name.h>
#include <library/cpp/yt/threading/public.h>
#include <util/datetime/base.h>
#include <util/system/getpid.h>
namespace NYT {
////////////////////////////////////////////////////////////////////////////////
//! When this guard is set, newly created errors do not have non-deterministic
//! system attributes and have "datetime" and "host" attributes overridden with a given values.
class TErrorSanitizerGuard
: public TNonCopyable
{
public:
TErrorSanitizerGuard(TInstant datetimeOverride, TSharedRef localHostNameOverride);
~TErrorSanitizerGuard();
private:
const bool SavedEnabled_;
const TInstant SavedDatetimeOverride_;
const TSharedRef SavedLocalHostNameOverride_;
};
bool IsErrorSanitizerEnabled() noexcept;
////////////////////////////////////////////////////////////////////////////////
struct TOriginAttributes
{
static constexpr size_t ExtensionDataByteSizeCap = 64;
using TErasedExtensionData = TErasedStorage<ExtensionDataByteSizeCap>;
TProcessId Pid;
NThreading::TThreadId Tid;
TThreadName ThreadName;
TInstant Datetime;
TSharedRef HostHolder;
mutable TStringBuf Host;
// Opaque storage for data from yt/yt/core.
// Currently may contain FiberId, TraceId, SpandId.
std::optional<TErasedExtensionData> ExtensionData;
bool operator==(const TOriginAttributes& other) const noexcept;
void Capture();
};
////////////////////////////////////////////////////////////////////////////////
namespace NDetail {
inline constexpr NGlobal::TVariableTag GetExtensionDataTag = {};
inline constexpr NGlobal::TVariableTag FormatOriginTag = {};
inline constexpr NGlobal::TVariableTag ExtractFromDictionaryTag = {};
////////////////////////////////////////////////////////////////////////////////
// These are "weak" symbols.
// NB(arkady-e1ppa): ExtractFromDictionary symbol is left in yt/yt/core/misc/origin_attributes
// because it depends on ytree for now.
std::optional<TOriginAttributes::TErasedExtensionData> GetExtensionData();
TString FormatOrigin(const TOriginAttributes& attributes);
} // namespace NDetail
////////////////////////////////////////////////////////////////////////////////
} // namespace NYT
|