File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Src/StackifyLib/Internal/Logs Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 33using System ;
44using System . Collections . Concurrent ;
55using System . Collections . Generic ;
6+ using System . Diagnostics ;
67using System . Linq ;
8+ using System . Reflection ;
9+ using System . Threading ;
710using System . Threading . Tasks ;
811
912#if NETFULL
@@ -99,6 +102,7 @@ public void QueueLogMessage(Models.LogMsg msg)
99102 // ignore
100103 }
101104
105+
102106#if NETFULL
103107 try
104108 {
@@ -177,6 +181,34 @@ public void QueueLogMessage(Models.LogMsg msg)
177181 }
178182 }
179183 }
184+ #else
185+ // else if .Net Core
186+ // get RequestID
187+ if ( string . IsNullOrEmpty ( msg . TransID ) )
188+ {
189+ var assemblies = AppDomain . CurrentDomain . GetAssemblies ( ) ;
190+
191+ var agentAssemblyQry = assemblies . Where ( assembly => assembly . FullName . Contains ( "Stackify.Agent" ) ) ;
192+ if ( agentAssemblyQry . Count ( ) > 0 )
193+ {
194+ var middleware = agentAssemblyQry . First ( ) ;
195+ var callContextType = middleware . GetType ( "Stackify.Agent.Threading.StackifyCallContext" ) ;
196+ if ( callContextType != null )
197+ {
198+ var traceCtxType = middleware . GetType ( "Stackify.Agent.Tracing.ITraceContext" ) ;
199+ if ( traceCtxType != null )
200+ {
201+ var traceContextProp = callContextType . GetProperty ( "TraceContext" ) ? . GetValue ( null ) ;
202+ if ( traceContextProp != null )
203+ {
204+ var reqIdProp = traceCtxType . GetProperty ( "RequestId" ) ? . GetValue ( traceContextProp ) ? . ToString ( ) ;
205+ if ( ! string . IsNullOrEmpty ( reqIdProp ) )
206+ msg . TransID = reqIdProp ;
207+ }
208+ }
209+ }
210+ }
211+ }
180212#endif
181213
182214 _MessageBuffer . Enqueue ( msg ) ;
You can’t perform that action at this time.
0 commit comments