#pragma once #include "public.h" #include #include #include #include #include #include #include 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; TProcessId Pid = 0; 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 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 GetExtensionData(); TString FormatOrigin(const TOriginAttributes& attributes); //////////////////////////////////////////////////////////////////////////////// // Weak symbol. TOriginAttributes ExtractFromDictionary(TErrorAttributes* attributes); // Default impl of weak symbol. TOriginAttributes ExtractFromDictionaryDefault(TErrorAttributes* attributes); } // namespace NDetail //////////////////////////////////////////////////////////////////////////////// } // namespace NYT