Coder Social home page Coder Social logo

graphite.net's Introduction

Graphite.NET

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.

Graphite

Usage

// Import namespace
using Graphite;

// ...

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

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

StatsD

Usage

// Import namespace
using Graphite.StatsD;

// ...

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

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

    // Decrement a counter by 5, sampled every 1/10th time
    client.Decrement("counter3", 5, 0.1); // sends 'foo.bar.counter3:-5|[email protected]

    // Report that the blahonga operation took 42 ms
    client.Timing("blahonga", 42); // sends 'foo.bar.blahonga:42|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:

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

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

graphite.net's People

Contributors

ragnard avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.