Skip to content

Commit

Permalink
Fix trace state parsing. (#638)
Browse files Browse the repository at this point in the history
- Without this the `.Value<string>` was exploding attempting to convert to a string.
  • Loading branch information
NTaylorMullen authored Aug 18, 2021
1 parent bcb734c commit b588faa
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/JsonRpc/Receiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,25 @@ protected virtual Renor GetRenor(JToken @object)

var properties = request.Properties().ToLookup(z => z.Name, StringComparer.OrdinalIgnoreCase);

var traceStateProperty = properties["tracestate"].FirstOrDefault();
var traceState = traceStateProperty?.Value.ToString();
var traceParentProperty = properties["traceparent"].FirstOrDefault();
var traceParent = traceParentProperty?.Value.ToString();

// id == request
// !id == notification
if (!hasRequestId)
{
return new Notification(method!, @params) {
TraceState = properties["tracestate"].FirstOrDefault()?.Value<string>(),
TraceParent = properties["traceparent"].FirstOrDefault()?.Value<string>()
TraceState = traceState,
TraceParent = traceParent,
};
}
else
{
return new Request(requestId!, method!, @params) {
TraceState = properties["tracestate"].FirstOrDefault()?.Value<string>(),
TraceParent = properties["traceparent"].FirstOrDefault()?.Value<string>()
TraceState = traceState,
TraceParent = traceParent,
};
}
}
Expand Down

0 comments on commit b588faa

Please sign in to comment.