45 if (activityInfo ==
null)
49 return $
"{Path(activityInfo.m_creator)}/{activityInfo.m_uniqueId}";
77 fixed (
Guid* outPtr = &idRet)
89 whereToAddId =
AddIdToGuid(outPtr, whereToAddId, (uint)num);
92 if (12 < activityPathGuidOffset)
103 if (creator.m_activityPathGuidOffset <= 10)
106 *outPtr = creator.m_guid;
107 int num =
AddIdToGuid(outPtr, creator.m_activityPathGuidOffset,
id, overflow:
true);
116 private unsafe
static int AddIdToGuid(
Guid* outPtr,
int whereToAddId, uint
id,
bool overflow =
false)
118 byte* ptr = (
byte*)outPtr;
119 byte* ptr2 = ptr + 12;
125 if (0 <
id &&
id <= 10 && !overflow)
136 else if (
id <= 65535)
140 else if (
id <= 16777215)
153 if (ptr < ptr2 && *ptr != 0)
157 *ptr = (byte)(192 + (
id >> 8));
174 *(
int*)((
byte*)outPtr + (nint)3 * (nint)4) = (
int)(*(uint*)outPtr + *(uint*)((
byte*)outPtr + 4) + *(uint*)((
byte*)outPtr + (nint)2 * (nint)4) + 1503500717) ^
Environment.
ProcessId;
175 return (
int)(ptr - (
byte*)outPtr);
182 byte* intPtr = ptr++;
183 *intPtr |= (byte)
value;
187 *ptr = (byte)(
value << 4);
222 TplEventSource tplEventSource = (useTplSource ? TplEventSource.Log :
null);
223 bool flag = tplEventSource?.
Debug ??
false;
231 if (
value.m_level >= 100)
244 if (activityInfo !=
null)
246 OnStop(providerName, activityName,
task, ref activityId);
254 m_current.Value = activityInfo2;
259 tplEventSource.
DebugFacilityMessage1(
"OnStartRet", activityId.ToString(), relatedActivityId.ToString());
263 public void OnStop(
string providerName,
string activityName,
int task, ref
Guid activityId,
bool useTplSource =
true)
270 TplEventSource tplEventSource = (useTplSource ? TplEventSource.Log :
null);
271 bool flag = tplEventSource?.
Debug ??
false;
284 if (activityInfo2 ==
null)
295 while (activityInfo3 != activityInfo2 && activityInfo3 !=
null)
304 if (activityInfo ==
null)
306 activityInfo = activityInfo3;
311 activityInfo3.m_stopped = 1;
317 if (activityInfo ==
null)
321 m_current.Value = activityInfo;
339 Debugger.
Log(0,
null,
"Activity Enabled() called but AsyncLocals Not Supported (pre V4.6). Ignoring Enable");
346 for (
ActivityInfo activityInfo = startLocation; activityInfo !=
null; activityInfo = activityInfo.
m_creator)
348 if (name == activityInfo.m_name && activityInfo.m_stopped == 0)
360 return providerName + activityName.AsSpan(0, activityName.Length -
"Start".Length);
364 return providerName + activityName.AsSpan(0, activityName.Length -
"Stop".Length);
368 return providerName +
"task" +
task;
370 return providerName + activityName;
382 while (activityInfo !=
null)
static void Log(int level, string? category, string? message)
static unsafe int AddIdToGuid(Guid *outPtr, int whereToAddId, uint id, bool overflow=false)
readonly EventActivityOptions m_eventOptions
static string LiveActivities(ActivityInfo list)
unsafe void CreateOverflowGuid(Guid *outPtr)
readonly int m_activityPathGuidOffset
static string Path(ActivityInfo activityInfo)
unsafe void CreateActivityPathGuid(out Guid idRet, out int activityPathGuidOffset)
readonly ActivityInfo m_creator
readonly Guid m_activityIdToRestore
override string ToString()
ActivityInfo(string name, long uniqueId, ActivityInfo creator, Guid activityIDToRestore, EventActivityOptions options)
static unsafe void WriteNibble(ref byte *ptr, byte *endPtr, uint value)
static ActivityInfo FindActiveActivity(string name, ActivityInfo startLocation)
static string NormalizeActivityName(string providerName, string activityName, int task)
void OnStart(string providerName, string activityName, int task, ref Guid activityId, ref Guid relatedActivityId, EventActivityOptions options, bool useTplSource=true)
static ActivityTracker Instance
void ActivityChanging(AsyncLocalValueChangedArgs< ActivityInfo > args)
void OnStop(string providerName, string activityName, int task, ref Guid activityId, bool useTplSource=true)
static readonly ActivityTracker s_activityTrackerInstance
AsyncLocal< ActivityInfo > m_current
static void SetCurrentThreadActivityId(Guid activityId)
static Guid CurrentThreadActivityId
static int CompareExchange(ref int location1, int value, int comparand)
static int Increment(ref int location)
void DebugFacilityMessage1(string Facility, string Message, string Value1)
static readonly TplEventSource Log
void DebugFacilityMessage(string Facility, string Message)
static readonly Guid Empty