Git Product home page Git Product logo

g2s's Introduction

g2s

Get to Statsd: forward simple statistics to a statsd server.

Build Status GoDoc

Usage

g2s provides a Statsd object, which provides some convenience functions for each of the supported statsd statistic-types. Just call the relevant function on the Statsd object wherever it makes sense in your code.

s, err := g2s.Dial("udp", "statsd-server:8125")
if err != nil {
	// do something
}

s.Counter(1.0, "my.silly.counter", 1)
s.Timing(1.0, "my.silly.slow-process", time.Since(somethingBegan))
s.Timing(0.2, "my.silly.fast-process", 7*time.Millisecond)
s.Gauge(1.0, "my.silly.status", "green")

If you use a standard UDP connection to a statsd server, all 'update'-class functions are goroutine safe. They should return quickly, but they're safe to fire in a separate goroutine.

The default timeout is 2 seconds, you can change that by using "DialTimeout":

s, err := g2s.DialTimeout("udp", "statsd-server:8125", time.Second)
if err != nil {
	// do something
}

If you use the built-in Dial or DialTimeout function g2s will attempt to reconnect when a write fails. This will happen rarely, if interface becomes invalid for a time.

Upgrading API

Upgrade to the latest API by running ./fix.bash *.go where *.go expands to the paths of the source files you'd like to rewrite to the new API.

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.