File tree Expand file tree Collapse file tree 1 file changed +19
-9
lines changed
Src/StackifyLib/Internal/Logs Expand file tree Collapse file tree 1 file changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -189,18 +189,28 @@ public void QueueLogMessage(Models.LogMsg msg)
189189 var trace = Trace . CorrelationManager . ActivityId ;
190190
191191 var q = AppDomain . CurrentDomain . GetAssemblies ( ) ;
192- var a = Assembly . GetEntryAssembly ( ) . GetReferencedAssemblies ( ) ;
193192
194193 var s = q . Where ( assembly => assembly . FullName . Contains ( "Stackify.Agent" ) ) ;
195- var middleware = s . First ( ) ;
196- var midTypes = middleware . GetTypes ( ) ;
197- var callContextType = middleware . GetType ( "Stackify.Agent.Threading.StackifyCallContext" ) ;
198- var traceCtxType = middleware . GetType ( "Stackify.Agent.Tracing.ITraceContext" ) ;
199- var traceContextProp = callContextType . GetProperty ( "TraceContext" ) ;
200- var traceFields = traceContextProp . GetValue ( null ) ;
201- if ( traceFields != null )
194+ if ( s . Count ( ) > 0 )
202195 {
203- msg . TransID = traceCtxType . GetProperty ( "RequestId" ) . GetValue ( traceFields ) . ToString ( ) ;
196+ var middleware = s . First ( ) ;
197+ var callContextType = middleware . GetType ( "Stackify.Agent.Threading.StackifyCallContext" ) ;
198+ if ( callContextType != null )
199+ {
200+ var traceCtxType = middleware . GetType ( "Stackify.Agent.Tracing.ITraceContext" ) ;
201+ if ( traceCtxType != null )
202+ {
203+ var traceContextProp = callContextType . GetProperty ( "TraceContext" ) ;
204+ if ( traceCtxType != null )
205+ {
206+ var traceFields = traceContextProp . GetValue ( null ) ;
207+ if ( traceFields != null )
208+ {
209+ msg . TransID = traceCtxType . GetProperty ( "RequestId" ) . GetValue ( traceFields ) . ToString ( ) ;
210+ }
211+ }
212+ }
213+ }
204214 }
205215 }
206216#endif
You can’t perform that action at this time.
0 commit comments