Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Src/StackifyLib/Internal/Logs/LogQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;

#if NETFULL
Expand Down Expand Up @@ -99,6 +102,7 @@ public void QueueLogMessage(Models.LogMsg msg)
// ignore
}


#if NETFULL
try
{
Expand Down Expand Up @@ -177,6 +181,34 @@ public void QueueLogMessage(Models.LogMsg msg)
}
}
}
#else
// else if .Net Core
// get RequestID
if (string.IsNullOrEmpty(msg.TransID))
{
var assemblies = AppDomain.CurrentDomain.GetAssemblies();

var agentAssemblyQry = assemblies.Where(assembly => assembly.FullName.Contains("Stackify.Agent"));
if(agentAssemblyQry.Count() > 0)
{
var middleware = agentAssemblyQry.First();
var callContextType = middleware.GetType("Stackify.Agent.Threading.StackifyCallContext");
if (callContextType != null)
{
var traceCtxType = middleware.GetType("Stackify.Agent.Tracing.ITraceContext");
if(traceCtxType != null)
{
var traceContextProp = callContextType.GetProperty("TraceContext")?.GetValue(null);
if (traceContextProp != null)
{
var reqIdProp = traceCtxType.GetProperty("RequestId")?.GetValue(traceContextProp)?.ToString();
if(!string.IsNullOrEmpty(reqIdProp))
msg.TransID = reqIdProp;
}
}
}
}
}
#endif

_MessageBuffer.Enqueue(msg);
Expand Down