Backfills trace injection test and migrates from request.params to request.params._meta (#360)
* Adds test to show where trace IDs are encoded Signed-off-by: Adrian Cole <adrian.cole@elastic.co> * update impl to params._meta Signed-off-by: Adrian Cole <adrian.cole@elastic.co> --------- Signed-off-by: Adrian Cole <adrian.cole@elastic.co>
This commit is contained in:
parent
2eeb61f4fa
commit
17a94272d9
1 changed files with 54 additions and 16 deletions
|
|
@ -50,22 +50,19 @@ internal static class Diagnostics
|
|||
fieldValues = null;
|
||||
fieldValue = null;
|
||||
|
||||
JsonNode? parameters = null;
|
||||
JsonNode? meta = null;
|
||||
switch (message)
|
||||
{
|
||||
case JsonRpcRequest request:
|
||||
parameters = request.Params;
|
||||
meta = request.Params?["_meta"];
|
||||
break;
|
||||
|
||||
case JsonRpcNotification notification:
|
||||
parameters = notification.Params;
|
||||
break;
|
||||
|
||||
default:
|
||||
meta = notification.Params?["_meta"];
|
||||
break;
|
||||
}
|
||||
|
||||
if (parameters?[fieldName] is JsonValue value && value.GetValueKind() == JsonValueKind.String)
|
||||
if (meta?[fieldName] is JsonValue value && value.GetValueKind() == JsonValueKind.String)
|
||||
{
|
||||
fieldValue = value.GetValue<string>();
|
||||
}
|
||||
|
|
@ -89,14 +86,17 @@ internal static class Diagnostics
|
|||
case JsonRpcNotification notification:
|
||||
parameters = notification.Params;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (parameters is JsonObject jsonObject && jsonObject[key] == null)
|
||||
// Replace any params._meta with the current value
|
||||
if (parameters is JsonObject jsonObject)
|
||||
{
|
||||
jsonObject[key] = value;
|
||||
if (jsonObject["_meta"] is not JsonObject meta)
|
||||
{
|
||||
meta = new JsonObject();
|
||||
jsonObject["_meta"] = meta;
|
||||
}
|
||||
meta[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue