DatadogStatsD 0.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package DatadogStatsD --version 0.2.0
NuGet\Install-Package DatadogStatsD -Version 0.2.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DatadogStatsD" Version="0.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DatadogStatsD --version 0.2.0
#r "nuget: DatadogStatsD, 0.2.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DatadogStatsD as a Cake Addin
#addin nuget:?package=DatadogStatsD&version=0.2.0

// Install DatadogStatsD as a Cake Tool
#tool nuget:?package=DatadogStatsD&version=0.2.0

DatadogStatsD

Full featured DogStatsD client:

Installation

DatadogStatsD targets .NET Standard 2.1.

dotnet add package DatadogStatsD

Examples

using var dogStatsD = new DogStatsD();

using var requests = dogStatsD.CreateCount("requests", new[] { "environment:dev" });
exampleMetric.Increment();
exampleMetric.Decrement();

using var latency = dogStatsD.CreateHistogram("latency", sampleRate: 0.5);
exampleMetric2.Record(5.423);
exampleMetric2.Record(1.27);

using var threads = dogStatsD.CreateGauge("threads", () => Process.GetCurrentProcess().Threads.Count);

dogStasD.RaiseEvent(AlertType.Info, "Bad thing happened", "This happened");
dogStasD.SendServiceCheck("is_connected", CheckStatus.Ok);

See DogStatsDConfiguration.cs to configure the client.

Benchmark

Benchmark comparing performance of this library with neuecc/DatadogSharp and DataDog/dogstatsd-csharp-client. Sources can be found in DatadogStatsD.Benchmark.

Count & Gauge

Method Op Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
DatadogStatsD 1000 8.480 us 0.1635 us 0.3554 us - - - -
DatadogSharp 1000 8,640.205 us 171.6157 us 390.8558 us 343.7500 - - 558880 B
StatsDClient 1000 9,928.695 us 168.0484 us 206.3785 us 578.1250 - - 912021 B
DatadogStatsD 10000 86.608 us 1.7011 us 2.6982 us - - - -
DatadogSharp 10000 84,551.941 us 1,679.0799 us 3,112.2822 us 3428.5714 - - 5598880 B
StatsDClient 10000 102,578.512 us 1,974.8266 us 4,416.9827 us 5800.0000 - - 9192000 B
DatadogStatsD 100000 862.448 us 17.0070 us 35.5000 us - - - -
DatadogSharp 100000 852,460.918 us 16,706.6878 us 29,260.4160 us 35000.0000 - - 56000000 B
StatsDClient 100000 1,001,979.915 us 20,012.3158 us 28,054.4718 us 58000.0000 - - 91992000 B

This library aggregates for 10 seconds (DogStatsD flush interval) counts and gauges, so for 10000 increments, one packet is sent, hence the ~0 bytes allocated.

Histogram, Set, Distribution

Method Op Mean Error StdDev Gen 0 Gen 1 Gen 2 Allocated
DatadogStatsD 1000 607.0 us 11.48 us 18.87 us - - - 384 B
DatadogSharp 1000 8,485.5 us 162.87 us 167.26 us 343.7500 - - 559013 B
StatsDClient 1000 10,053.5 us 200.77 us 396.29 us 578.1250 - - 912000 B
DatadogStatsD 10000 5,955.4 us 118.61 us 170.11 us - - - 3196 B
DatadogSharp 10000 87,439.0 us 1,722.20 us 3,670.14 us 3500.0000 - - 5599101 B
StatsDClient 10000 104,099.7 us 2,063.75 us 3,504.41 us 5800.0000 - - 9192000 B
DatadogStatsD 100000 60,332.3 us 1,202.28 us 3,291.21 us - - - 23940 B
DatadogSharp 100000 867,484.8 us 17,075.68 us 22,203.21 us 35000.0000 - - 56000000 B
StatsDClient 100000 972,766.1 us 19,108.68 us 28,600.97 us 58000.0000 - - 91993400 B

For those metrics, the library lets DogStatsD agent do the aggregation, so with a sample rate of 1.0, each call to Histogram.Update will be sent to the agent.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.3.0 211,764 10/26/2020
0.2.5 513 10/8/2020
0.2.4 498 7/26/2020
0.2.3 520 6/18/2020
0.2.2 421 6/14/2020
0.2.1 384 6/11/2020
0.2.0 386 6/10/2020
0.1.3 442 4/28/2020
0.1.2 657 3/30/2020
0.1.1 483 3/20/2020
0.1.0 490 3/20/2020