(
void)
const{
returnm_HitId.empty(); }
82 if( IsShared() )
return;
84m_SharedSubHitId->GetData().Set(m_SubHitId);
88 bool IsShared(
void)
const{
return!m_SharedSubHitId.Empty(); }
91 const string&
GetHitId(
void)
const{
returnm_HitId; }
96m_SharedSubHitId.Reset();
107 returnIsShared() ? (
TSubHitId)m_SharedSubHitId->GetData().Get() : m_SubHitId;
113 returnIsShared() ? (
TSubHitId)m_SharedSubHitId->GetData().Add(1) : ++m_SubHitId;
126 voidx_SetHitId(
const string& hit_id);
186 virtual void SetName(
const string& name) = 0;
218 TCountGetRequestID(
void)
const;
220 voidSetRequestID(
TCountrid);
222 boolIsSetRequestID(
void)
const;
224 voidUnsetRequestID(
void);
226 TCountSetRequestID(
void);
229 static TCountGetNextRequestID(
void);
236 stringGetClientIP(
void)
const;
237 voidSetClientIP(
const string&
client);
238 boolIsSetClientIP(
void)
const;
239 boolIsSetExplicitClientIP(
void)
const;
240 voidUnsetClientIP(
void);
243 stringGetSessionID(
void)
const;
244 voidSetSessionID(
const string& session);
245 boolIsSetSessionID(
void)
const;
246 boolIsSetExplicitSessionID(
void)
const;
247 voidUnsetSessionID(
void);
249 const string& SetSessionID(
void);
251 stringGetEncodedSessionID(
void)
const;
258eHitID_Request = 0x01,
259eHitID_Default = 0x02,
263eHidID_Existing = eHitID_Default | eHitID_Request
274 voidSetHitID(
const string& hit);
282 boolIsSetHitID(EHitIDSource src = eHitID_Any)
const;
287{
returnIsSetHitID(eHitID_Request); }
289 voidUnsetHitID(
void);
292 const string& SetHitID(
void);
299 boolIsSetDtab(
void)
const;
300 const string& GetDtab(
void)
const;
301 voidSetDtab(
const string& dtab);
302 voidUnsetDtab(
void);
305 intGetRequestStatus(
void)
const;
306 voidSetRequestStatus(
intstatus);
308 boolIsSetRequestStatus(
void)
const;
309 voidUnsetRequestStatus(
void);
316 Int8GetBytesRd(
void)
const;
317 voidSetBytesRd(
Int8bytes);
318 boolIsSetBytesRd(
void)
const;
319 voidUnsetBytesRd(
void);
322 Int8GetBytesWr(
void)
const;
323 voidSetBytesWr(
Int8bytes);
324 boolIsSetBytesWr(
void)
const;
325 voidUnsetBytesWr(
void);
334 voidSetProperty(
const string& name,
const string&
value);
336 const string& GetProperty(
const string& name)
const;
338 boolIsSetProperty(
const string& name)
const;
340 voidUnsetProperty(
const string& name);
354 static voidSetDefaultAutoIncRequestIDOnPost(
boolenable);
356 static boolGetDefaultAutoIncRequestIDOnPost(
void);
374 static boolIsValidSessionID(
const string& session_id);
377 staticEOnBadSessionID GetBadSessionIDAction(
void);
378 static voidSetBadSessionIDAction(EOnBadSessionID action);
381 staticESessionIDFormat GetAllowedSessionIDFormat(
void);
382 static voidSetAllowedSessionIDFormat(ESessionIDFormat fmt);
397 static stringSelectLastHitID(
const string& hit_ids);
400 static stringSelectLastSessionID(
const string& session_ids);
403 voidAddPassThroughProperty(
const string& name,
const string&
value);
433 static voidSetRequestTracer(
constshared_ptr<IRequestTracer>& tracer);
440 void SetTracerSpan(
constshared_ptr<ITracerSpan>& span) { m_TracerSpan = span; }
441shared_ptr<ITracerSpan>
GetTracerSpan(
void)
const{
returnm_TracerSpan; }
446 const stringGetTraceState(
void)
const;
447 const stringGetTraceParent(
void)
const;
470 voidStartRequest(
void);
474 voidStopRequest(
void);
480eProp_RequestID = 1 << 0,
481eProp_ClientIP = 1 << 1,
482eProp_SessionID = 1 << 2,
483eProp_HitID = 1 << 3,
484eProp_ReqStatus = 1 << 4,
485eProp_BytesRd = 1 << 5,
486eProp_BytesWr = 1 << 6,
491 boolx_IsSetProp(
EPropertyprop)
const;
498 void x_LogHitID(
boolignore_app_state =
false)
const;
503 voidx_UpdateSubHitID(
boolincrement,
CTempStringprefix);
505 static bool& sx_GetDefaultAutoIncRequestIDOnPost(
void);
508 boolx_IsSetPassThroughProp(
CTempStringname,
boolupdate)
const;
510 const string& x_GetPassThroughProp(
CTempStringname,
boolupdate)
const;
511 voidx_ResetPassThroughProp(
CTempStringname,
boolupdate)
const;
513 voidx_UpdateStdPassThroughProp(
CTempStringname)
const;
515 voidx_UpdateStdContextProp(
CTempStringname)
const;
517 static const CMask& sx_GetContextFieldsMask(
void);
518 static stringsx_NormalizeContextPropertyName(
const string& name);
521 voidx_LoadEnvContextProperties(
void);
523 friend classCDiagBuffer;
524 boolx_LogHitIDOnError(
void)
const;
526 boolx_CanModify(
void)
const;
529 voidx_Modify(
void);
532fLoggedOnRequest = 1,
628 template<
classTCallback>
631m_Context->x_UpdateStdPassThroughProp(
"");
633 if( !callback(it->first, it->second) )
break;
638 stringx_SerializeUrlEncoded(
void)
const;
653fPrintRequestStart = 1 << 0
672 void SetStatus(
intstatus) { m_RequestContext->SetRequestStatus(status); }
676 voidSetDefaultErrorStatus(
intstatus);
683 voidRelease(
void);
687 intm_ErrorStatus = 500;
690 boolm_OriginatesFromThrow =
false;
707 virtual const char* GetErrCodeString(
void)
const override;
790 if( !def_sid.empty() )
returndef_sid;
1045 ERR_POST_ONCE(
"Attempt to modify a read-only request context.");
Thread local context data stored in TLS.
EFormat
The formats are checked in the same order as declared here.
Take guard of the current CRequestContext, handle app-state, start/stop logging and request status in...
Request context properties passed between tasks.
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
The NCBI C++ standard methods for dealing with std::string.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
TNCBIAtomicValue TValue
Alias TValue for TNCBIAtomicValue.
TValue Add(int delta) THROWS_NONE
Atomically add value (=delta), and return new counter value.
EContextFlags
Request context flags.
bool IsSetRequestID(void) const
Check if request ID was assigned a value.
CStopWatch & GetRequestTimer(void)
CRequestContext & GetRequestContext() const
Get the guarded request context.
TSubHitId GetNextSubHitId(void)
Get next sub-hit id value.
virtual const string & GetTraceState(void) const =0
void UnsetRequestStatus(void)
ESessionIDFormat
Session ID format.
bool IsSetBytesRd(void) const
TCount SetRequestID(void)
Assign the next available request ID to this request.
void SetBytesWr(Int8 bytes)
CEncodedString m_SessionID
EErrCode
Error types that CRequestContext can generate.
int GetRequestStatus(void) const
Request exit status.
#define ERR_POST_ONCE(message)
Error posting only once during program execution.
Uint8 TCount
Generic type for counters (posts, requests etc.)
Int8 GetBytesWr(void) const
Bytes written.
CObjectFor< CAtomicCounter > TSharedCounter
virtual void SetCustomAttribute(const string &attr, const string &value)=0
string GetEncodedSessionID(void) const
Get url-encoded session id.
CDiagContext & GetDiagContext(void)
Get diag context instance.
void SetTracerSpanKind(ITracerSpan::ESpanKind kind)
At least Opentememetry tracer allows to set span kind only at span creation time.
TProperties & GetProperties(void)
Get all properties (non-const)
bool GetAutoIncRequestIDOnPost(void) const
Get auto-increment state.
TSubHitId GetCurrentSubHitId(void) const
Get current sub-hit id value.
CRef< CRequestContext > m_SavedContext
void SetTracerSpan(const shared_ptr< ITracerSpan > &span)
map< string, string, PNocase > TPassThroughProperties
void x_SetProp(EProperty prop)
void Reset(CTempString name)
Reset property.
bool GetDisabledAppLog(void) const
string GetSessionID(void) const
Session ID.
CAtomicCounter::TValue TVersion
void SetSrcTraceParent(const string &parent)
void SetSrcTraceState(const string &state)
OpenTelemetry: set the incoming 'tracestate' and 'traceparent' values.
bool IsSetRequestStatus(void) const
bool x_IsSetProp(EProperty prop) const
const string & GetNextSubHitID(CTempString prefix=CTempString())
Get current hit id appended with auto-incremented sub-hit id.
bool IsSetBytesWr(void) const
void SetDtab(const string &dtab)
Int8 GetBytesRd(void) const
Bytes read.
static unique_ptr< TPassThroughProperties > sm_EnvContextProperties
static TCount GetNextRequestID(void)
Return the next available application-wide request ID.
CSharedHitId(const string &hit_id)
Set new hit id, checks its validity.
const string & Get(CTempString name) const
Get current property value or empty string if it's not set;.
map< string, string > TProperties
User-defined request properties.
shared_ptr< ITracerSpan > GetTracerSpan(void) const
virtual void PostEvent(const SDiagMessage &message)=0
CRef< TSharedCounter > m_SharedSubHitId
bool IsSetSessionID(void) const
void SetStatus(int status)
Set request context status.
TCount GetRequestID(void) const
Get request ID (or zero if not set).
CRequestContext_PassThrough(void)
Get CRequestContext_PassThrough for the current request context.
string GetClientIP(void) const
Client IP/hostname.
virtual ~IRequestTracer(void)
virtual const string & GetTraceParent(void) const =0
void x_LogHitID(void) const
void x_SetPassThroughProp(CTempString name, CTempString value, bool update) const
void SetHitId(const string &hit_id)
Set new hit id value. This resets sub-hit counter and makes it non-shared.
static shared_ptr< IRequestTracer > sm_Tracer
static string GetDefaultClientIP(void)
Get default client ip.
const string & GetSrcTraceParent(void) const
CDiagContext::EDisabledAppLogEvents GetDisabledAppLogEvents(void) const
void Enumerate(TCallback callback)
Enumerate all properties.
void SetAutoIncRequestIDOnPost(bool enable)
Auto-increment request ID with every posted message.
void SetRequestStatus(int status)
bool IsSetHitID(EHitIDSource src=eHitID_Any) const
Check if there's an explicit hit id or the default one.
virtual void EndSpan(void)=0
bool IsSet(CTempString name) const
Check if the property is set.
void UnsetRequestID(void)
Reset request ID.
const string & GetDtab(void) const
virtual void SetName(const string &name)=0
static CAtomicCounter sm_VersionCounter
bool x_IsSetPassThroughProp(CTempString name, bool update) const
bool x_LogHitIDOnError(void) const
const string GetTraceState(void) const
OpenTelemetry: get 'tracestate' and 'traceparent' values to be passed in HTTP headers.
CDiagContext::EDisabledAppLogEvents m_DisabledAppLogEvents
EHitIDSource
Hit ID Allowed source of the current hit id.
const CStopWatch & GetRequestTimer(void) const
Request execution timer.
EFormat
Supported serialization/deserialization formats.
CRef< CRequestContext > m_Context
static unique_ptr< CMaskFileName > sm_ContextFields
bool GetReadOnly(void) const
Get current read-only flag.
bool IsSetDtab(void) const
Dtab.
ITracerSpan::ESpanKind m_SpanKind
void UnsetSessionID(void)
bool IsSetExplicitClientIP(void) const
const string & x_GetPassThroughProp(CTempString name, bool update) const
void x_ResetPassThroughProp(CTempString name, bool update) const
bool IsRunning(void) const
EDisabledAppLogEvents
Flags for disabling groups of applog events with DIAG_DISABLE_APPLOG_MESSAGES.
void Set(CTempString name, CTempString value)
Set or update property value.
const string & SetSessionID(void)
Create and set new session ID.
CRequestContext & operator=(const CRequestContext &)
bool IsSetExplicitHitID(void) const
Check if there's an explicit hit id.
void SetBytesRd(Int8 bytes)
const string GetTraceParent(void) const
ITracerSpan::ESpanKind GetTracerSpanKind(void) const
EDiagAppState
Application execution states shown in the std prefix.
bool IsSetClientIP(void) const
shared_ptr< ITracerSpan > m_TracerSpan
bool IsShared(void) const
Check if shared counter is used.
SDiagMessage::TCount TCount
EOnBadSessionID
Session ID error actions.
virtual void SetSpanStatus(ESpanStatus status)=0
EDiagAppState GetAppState(void) const
Return application state for the current thread if it's set.
void UnsetHitID(void)
Reset explicit hit id.
const string & GetSrcTraceState(void) const
The getters provide access to the incoming values (unlike GetTraceState and GetTraceParent which retu...
string GetHitID(void) const
Get explicit hit id or the default one (from HTTP_NCBI_PHID etc).
virtual void OnRequestStart(CRequestContext &context)=0
virtual void SetHttpHeader(EHttpHeaderType header_type, const string &name, const string &value)=0
const TProperties & GetProperties(void) const
Get all properties (read only)
virtual void OnRequestStop(CRequestContext &context)=0
NCBI_EXCEPTION_DEFAULT(CRequestContextException, CException)
bool IsSetExplicitSessionID(void) const
Does not check default SID.
TPassThroughProperties m_PassThroughProperties
TVersion GetVersion(void) const
Return version increased on every context change (hit/subhit id, client ip, session id).
virtual ~ITracerSpan(void)
void SetShared(void) const
Mark this hit id as a shared one and start using shared counter.
void SetReadOnly(bool read_only)
Switch request context to read-only mode.
CRequestContext::TPassThroughProperties TProperties
shared_ptr< IRequestTracer > m_Tracer
const string & GetHitId(void) const
Get hit id value.
string GetDefaultSessionID(void) const
Get default session id.
virtual void SetAttribute(ESpanAttribute attr, const string &value)=0
CRequestContext(const CRequestContext &)
bool IsRequestLevel(void) const
Check if this hit ID was set at request level.
void x_UnsetProp(EProperty prop)
const string & GetCurrentSubHitID(CTempString prefix=CTempString())
Get the last generated sub-hit id.
void x_UpdateSubHitID(bool increment, CTempString prefix)
void SetDisabledAppLog(bool disable)
CRef< CRequestContext > m_RequestContext
string GetEncodedSessionID(void) const
Get URL-encoded session ID.
bool x_CanModify(void) const
void SetDisabledAppLogEvents(CDiagContext::EDisabledAppLogEvents events)
@ eSID_Ncbi
Strict NCBI format: (UID:16)_(RqID:4+)SID.
@ eSID_Standard
Alpanum, underscore, -.:@, (default)
@ eBadSession
Invalid session id.
@ eHitID_Request
Check if per-request hit id is set.
@ eHitID_Default
Check if default hit id is set.
@ eHitID_Any
Any hit id - always return true.
@ eDiagAppState_RequestEnd
RE.
@ eDiagAppState_RequestBegin
RB.
@ eDiagAppState_Request
R.
@ eOnBadSID_Allow
Don't validate session id.
@ eOnBadSID_IgnoreAndReport
Ignore and show warning.
@ eOnBadSID_AllowAndReport
Accept but show warning (default).
@ eOnBadSID_Ignore
Ignore bad session id.
#define EXCEPTION_VIRTUAL_BASE
Do not use virtual base classes in exception declaration at all, because in this case derived class s...
void Reset(void)
Reset reference object.
int64_t Int8
8-byte (64-bit) signed integer
uint64_t Uint8
8-byte (64-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
const string & GetEncodedString(void) const
Get encoded string.
const string & GetOriginalString(void) const
Get the original unencoded string.
void SetString(const CTempString s, NStr::EUrlEncode flag=NStr::eUrlEnc_SkipMarkChars)
Set new original string.
#define NCBI_XNCBI_EXPORT
The blob sat and sat key Both must be positive integers</td > n< td > Non empty string The interpretation of the blob id depends on a processor Cassandra n processor expects the following format
const TYPE & Get(const CNamedParameterList *param)
const GenericPointer< typename T::ValueType > T2 value
Defines NCBI C++ diagnostic APIs, classes, and macros.
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
Defines: CTimeFormat - storage class for time format.
Defines CRequestStatus class for NCBI C++ diagnostic API.
static CNamedPipeClient * client
void Serialize(CNcbiOstream &, const CRawScoreVector< Key, Score > &)
Generics These throw an exception; we must implement serialization for each type.
void Deserialize(CNcbiIstream &istr, CRawScoreVector< Key, Score > &)
static CS_CONTEXT * context
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4