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 3
3
using System ;
4
4
using System . Collections . Concurrent ;
5
5
using System . Collections . Generic ;
6
+ using System . Diagnostics ;
6
7
using System . Linq ;
8
+ using System . Reflection ;
9
+ using System . Threading ;
7
10
using System . Threading . Tasks ;
8
11
9
12
#if NETFULL
@@ -99,6 +102,7 @@ public void QueueLogMessage(Models.LogMsg msg)
99
102
// ignore
100
103
}
101
104
105
+
102
106
#if NETFULL
103
107
try
104
108
{
@@ -177,6 +181,34 @@ public void QueueLogMessage(Models.LogMsg msg)
177
181
}
178
182
}
179
183
}
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
+ }
180
212
#endif
181
213
182
214
_MessageBuffer . Enqueue ( msg ) ;
Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ public static string GetDeviceName()
129
129
}
130
130
}
131
131
132
- return deviceName ;
132
+ return deviceName . Substring ( 0 , deviceName . Length > 60 ? 60 : deviceName . Length ) ;
133
133
}
134
134
135
135
public static string GetEC2InstanceId ( )
@@ -215,7 +215,7 @@ public static string GetDeviceName()
215
215
}
216
216
}
217
217
218
- return deviceName ;
218
+ return deviceName . Substring ( 0 , deviceName . Length > 60 ? 60 : deviceName . Length ) ;
219
219
}
220
220
221
221
public static async Task < string > GetEC2InstanceId ( )
@@ -233,6 +233,11 @@ public static async Task<string> GetEC2InstanceId()
233
233
{
234
234
string id = await content . Content . ReadAsStringAsync ( ) ;
235
235
r = string . IsNullOrWhiteSpace ( id ) ? null : id ;
236
+
237
+ if ( r . Contains ( "html" ) )
238
+ {
239
+ r = Environment . MachineName ;
240
+ }
236
241
}
237
242
238
243
}
You can’t perform that action at this time.
0 commit comments