|
|
@@ -4,6 +4,7 @@ |
|
|
|
using System; |
|
|
|
using System.ComponentModel; |
|
|
|
using System.Reflection; |
|
|
|
using DotNetCore.CAP.Diagnostics; |
|
|
|
using Newtonsoft.Json; |
|
|
|
using Newtonsoft.Json.Linq; |
|
|
|
|
|
|
@@ -48,7 +49,7 @@ namespace DotNetCore.CAP.Infrastructure |
|
|
|
public static long ToTimestamp(DateTime value) |
|
|
|
{ |
|
|
|
var elapsedTime = value - Epoch; |
|
|
|
return (long) elapsedTime.TotalSeconds; |
|
|
|
return (long)elapsedTime.TotalSeconds; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@@ -90,6 +91,12 @@ namespace DotNetCore.CAP.Infrastructure |
|
|
|
return AddJsonProperty(json, "ExceptionMessage", jObject); |
|
|
|
} |
|
|
|
|
|
|
|
public static string AddTracingHeaderProperty(string json, TracingHeaders headers) |
|
|
|
{ |
|
|
|
var jObject = ToJObject(headers); |
|
|
|
return AddJsonProperty(json, "TracingHeaders", jObject); |
|
|
|
} |
|
|
|
|
|
|
|
public static bool IsInnerIP(string ipAddress) |
|
|
|
{ |
|
|
|
bool isInnerIp; |
|
|
@@ -156,6 +163,16 @@ namespace DotNetCore.CAP.Infrastructure |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
private static JObject ToJObject(TracingHeaders headers) |
|
|
|
{ |
|
|
|
var jobj = new JObject(); |
|
|
|
foreach (var keyValuePair in headers) |
|
|
|
{ |
|
|
|
jobj[keyValuePair.Key] = keyValuePair.Value; |
|
|
|
} |
|
|
|
return jobj; |
|
|
|
} |
|
|
|
|
|
|
|
private static string AddJsonProperty(string json, string propertyName, JObject propertyValue) |
|
|
|
{ |
|
|
|
var jObj = JObject.Parse(json); |
|
|
|