This PR changes the log formatter so that it depends on System.Text.Json rather than Newtonsoft.Json when .NET 5+ is the target runtime. Doing so yields a 90% performance boost in execution time over Newtonsoft.Json (Newtonsoft.Json is still used by .NET framework and standard targets to preserve their behavior.)
I've also changed the type used for the payload from Dictionary<string, dynamic> to Dictionary<string, object>. It wasn't clear why dynamic was used, but the runtime overhead of dynamic when compared to boxing is noticeable.
To help with testing I've added an extra parameter on the sink to pass in an implementation of IDatadogClient which was already public.
Finally, this fixes an unnecessary reference to System.Http being added to .NET 5+ projects.
A diff of the serialized log events shows they are 1:1
This PR changes the log formatter so that it depends on System.Text.Json rather than Newtonsoft.Json when .NET 5+ is the target runtime. Doing so yields a 90% performance boost in execution time over Newtonsoft.Json (Newtonsoft.Json is still used by .NET framework and standard targets to preserve their behavior.)
I've also changed the type used for the payload from
Dictionary<string, dynamic>
toDictionary<string, object>
. It wasn't clear why dynamic was used, but the runtime overhead of dynamic when compared to boxing is noticeable.To help with testing I've added an extra parameter on the sink to pass in an implementation of
IDatadogClient
which was already public.Finally, this fixes an unnecessary reference to System.Http being added to .NET 5+ projects.
A diff of the serialized log events shows they are 1:1![image](https://user-images.githubusercontent.com/1297077/139377116-43efec5e-b8eb-4b2a-8b95-fd3a182775bf.png)