Skip to content

Commit 29b9d00

Browse files
committed
- make code more concise with coalesce chains
- add Stackify.json
1 parent c4b0c9d commit 29b9d00

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

Src/StackifyLib/Internal/Logs/LogQueue.cs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -200,24 +200,12 @@ public void QueueLogMessage(Models.LogMsg msg)
200200
var traceCtxType = middleware.GetType("Stackify.Agent.Tracing.ITraceContext");
201201
if(traceCtxType != null)
202202
{
203-
var traceContextProp = callContextType.GetProperty("TraceContext");
204-
if(traceContextProp != null)
203+
var traceContextProp = callContextType.GetProperty("TraceContext")?.GetValue(null);
204+
if (traceContextProp != null)
205205
{
206-
var traceFields = traceContextProp.GetValue(null);
207-
if (traceFields != null)
208-
{
209-
var reqIdProp = traceCtxType.GetProperty("RequestId");
210-
211-
if (reqIdProp != null)
212-
{
213-
var transIDVal = reqIdProp.GetValue(traceFields);
214-
if (transIDVal != null)
215-
{
216-
msg.TransID = transIDVal.ToString();
217-
}
218-
}
219-
220-
}
206+
var reqIdProp = traceCtxType.GetProperty("RequestId")?.GetValue(traceContextProp)?.ToString();
207+
if(!string.IsNullOrEmpty(reqIdProp))
208+
msg.TransID = reqIdProp;
221209
}
222210
}
223211
}

samples/CoreWebApp/Stackify.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"AppName": "Ray Log Test",
3+
"Environment": "Ray Log"
4+
}

0 commit comments

Comments
 (0)