File tree Expand file tree Collapse file tree 2 files changed +39
-2
lines changed
Expand file tree Collapse file tree 2 files changed +39
-2
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 ) ;
Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ public static string GetDeviceName()
129129 }
130130 }
131131
132- return deviceName ;
132+ return deviceName . Substring ( 0 , deviceName . Length > 60 ? 60 : deviceName . Length ) ;
133133 }
134134
135135 public static string GetEC2InstanceId ( )
@@ -215,7 +215,7 @@ public static string GetDeviceName()
215215 }
216216 }
217217
218- return deviceName ;
218+ return deviceName . Substring ( 0 , deviceName . Length > 60 ? 60 : deviceName . Length ) ;
219219 }
220220
221221 public static async Task < string > GetEC2InstanceId ( )
@@ -233,6 +233,11 @@ public static async Task<string> GetEC2InstanceId()
233233 {
234234 string id = await content . Content . ReadAsStringAsync ( ) ;
235235 r = string . IsNullOrWhiteSpace ( id ) ? null : id ;
236+
237+ if ( r . Contains ( "html" ) )
238+ {
239+ r = Environment . MachineName ;
240+ }
236241 }
237242
238243 }
You can’t perform that action at this time.
0 commit comments