DataDog / serilog-sinks-datadog-logs

Serilog Sink that sends log events to Datadog https://www.datadoghq.com/
Apache License 2.0
60 stars 41 forks source link

.NET 5 and .NET 6 support #68

Closed andrewmd5 closed 2 years ago

andrewmd5 commented 2 years ago

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.)

image

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 image

andrewmd5 commented 2 years ago

@ogaca-dd once this has been reviewed / approved I also have a bunch of performance improvements on this branch I'll be submitting too.

strigona commented 2 years ago

Any news on when this change will be released?