Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

.NET client library for Graphite and StatsD

branch: master

Bump version

latest commit cfddaa90e1
Ragnar Dahlén authored September 25, 2011
Octocat-spinner-32 Graphite Bump version September 25, 2011
Octocat-spinner-32 .gitignore Create nuspec package September 24, 2011
Octocat-spinner-32 Graphite.NET.sln Remove temp. project September 25, 2011
Octocat-spinner-32 LICENSE Format LICENSE September 24, 2011
Octocat-spinner-32 Fix errors in README. September 25, 2011


A simple Graphite client library for .NET, including a WCF behavior for measuring duration of service operation calls.

A client for StatsD is also included.



// Import namespace
using Graphite;

// ...

// Create an UDP client for sending metrics to "localhost:2003", prefixing all keys with ""
using(var client = new GraphiteUdpClient("localhost", 2003, ""))
    // Report a metric
    client.Send("baz", 93284928374);

    // Report a metric specifying timestamp
    client.Send("baz", 93284928374, DateTime.Now.AddSeconds(42));



// Import namespace
using Graphite.StatsD;

// ...

// Create a client for sending metrics to "localhost:8125", prefixing all keys with ""
using(var client = new StatsDClient("localhost", 8125, ""))
    // Increment a counter
    client.Incremenet("counter1"); // sends '|c'

    // Increment a counter by 42
    client.Incremenet("counter2", 42); // sends '|c'

    // Decrement a counter by 5, sampled every 1/10th time
    client.Decrement("counter3", 5, 0.1); // sends '|c@0.1

    // Report that the blahonga operation took 42 ms
    client.Timing("blahonga", 42); // sends '|ms'

WCF endpoint behavior

Also included with Graphite.NET is a WCF endpoint behavior that measures and reports the duration of service operation invocations.

Currently only support for StatsD is implemented.

To use the behavior, first register it as an behavior extension, then use it in suitable endpointBehavior elements.

The behavior will time all service operation invocations, sending metrics on the form KeyPrefix.ContractName.OperationName.

Example configuration:

  <!-- Register behavior extension -->
        <add name="timeOperations" type="Graphite.WCF.OperationTimingEndpointBehaviorExtensionElement, Graphite" />
    <!-- Use the behavior where suitable -->
        <behavior name="...">
          <timeOperations hostname="..." port="..." keyPrefix="..." />

The OperationTimingEndpointBehaviorExtensionElement has three attributes:

  • hostname (required): address to StatsD instance
  • port (optional, default is 8125): the port StatsD is listening on
  • keyPrefix (optional, default is none): namespace to prefix keys with
Something went wrong with that request. Please try again.