Prepared nuget package spec. Added a bit more documentation.

This commit is contained in:
Luke Venediger
2013-04-22 00:54:24 +02:00
parent caa66f9b41
commit 2daa84286e
6 changed files with 47 additions and 31 deletions

Binary file not shown.

View File

@@ -11,29 +11,39 @@ A simple c# client library for [statsd.net](https://github.com/lukevenediger/sta
* Supports a user-defined prefix to prepend to every metric
## Coming soon
* Support for sets and count sampling
* batch-and-pump - collecting stats and sending them out in a batch at regular intervals
* Output to an HTTP endpoint
## Usage
Create an instance of StatsdClient to get started:
```csharp
var statsd = new StatsdClient(
You can specify your metrics as a string:
## Quickstart
Assuming your statsd.net server is running on localhost and listening on port 12000:
```csharp
var statsd = new StatsdClient("localhost", 12000);
// Log a count
statsd.LogCount( "site.hits" );
statsd.LogTiming( "site.pageLoad", 100 /* milliseconds */ );
// Log a gauge
statsd.LogGauge( "site.activeUsers", numActiveUsers );
// Log a timing
statsd.LogTiming( "site.pageLoad", 100 /* milliseconds */ );
```
You can also use the dynamic stats builder:
You can also wrap your code in a `using` block to measure the latency:
```csharp
_.count.site.hits + 1 > statsd;
_.timing.site.pageLoad + 100 > statsd;
_.gauge.site.activeUsers + numActiveUsers > statsd;
'''
using (statsd.LogTiming( "site.db.fetchReport" ))
{
// do some work
}
// At this point your latency has been sent to the server
```
[statsd]: https://github.com/etsy/statsd
[statsd.net]: https://github.com/lukevenediger/statsd.net
## Dynamic Stats Builder
There's also a nifty set of extension methods that let you define your stats without using strings. Using the example provided above, but now using the builder:
```csharp
var statsd = new StatsdClient("localhost", 12000);
// Log a count
statsd.count.site.hits += 1;
// Log a gauge
statsd.gauge.site.activeUsers += numActiveUsers;
// Log a timing
statsd.site.pageLoad += 100; /* milliseconds */
```

View File

@@ -6,9 +6,9 @@ using System.Runtime.InteropServices;
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("StatsdClient")]
[assembly: AssemblyDescription("A statsd and statsd.net client for c#")]
[assembly: AssemblyDescription("A statsd.net and statsd client for c#")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyCompany("Luke Venediger")]
[assembly: AssemblyProduct("StatsdClient")]
[assembly: AssemblyCopyright("Copyright © Luke Venediger 2013")]
[assembly: AssemblyTrademark("")]

View File

@@ -49,7 +49,9 @@
<Compile Include="StatsdClientExtensions.cs" />
<Compile Include="TimingToken.cs" />
<Compile Include="UdpOutputChannel.cs" />
<Compile Include="_.cs" />
</ItemGroup>
<ItemGroup>
<None Include="StatsdClient.nuspec" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>StatsdCsharpClient</id>
<version>$version$</version>
<title>$title$</title>
<authors>Luke Venediger</authors>
<owners>Luke Venediger</owners>
<projectUrl>https://github.com/lukevenediger/statsd-csharp-client/</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<releaseNotes>First release of the statsd c# client.</releaseNotes>
<copyright>Copyright 2013 Luke Venediger</copyright>
<tags>statsd statsd.net graphite</tags>
</metadata>
</package>

View File

@@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StatsdClient
{
public interface _ : IStatsd
{
}
}