Giter VIP home page Giter VIP logo

graphite-client's Introduction

A Graphite A go library for sending metrics to graphite.

Usage

import (
        "github.com/openmetric/graphite-client"
)

// Create a client
client := graphite.NewClient("tcp://127.0.0.1:2003", "", 1*time.Second)

// Create a Metric instance, and send this metric
metric := &graphite.Metric{
	Name:      "test.int",
	Value:     1,
	Timestamp: time.Now().Unix(),
}
client.SendMetric(metric)

// Send something without create a Metric instance,
// if timestamp is 0, time.Now() is used automatically.
client.SendSimple("test.int", 2, 0)

// Shutdown will block the caller until all metrics in buffer have been sent, or timeout occurs.
// If timeout occurs before all metrics flushed, metrics left in buffer will be lost.
client.Shutdown(1*time.Second)

// ---------------------------------------------

// Name of all metrics sent by this client will be prefixed with 'myprogram.'
prefixedClient := graphite.NewClient("udp://127.0.0.1:2003", "myprogram.", 1*time.Second)

// Server will get: 'myprogram.test.float 1.2 1493795673'
client.SendSimple("test.float", 1.2, 1493795673)

client.Shutdown()

// ---------------------------------------------

// NopClient just silently drops all data.
if config.DisableGraphite {
	client := graphite.NewNopClient()
}
client.SendSimple("any.metric", 0, 0)
client.Shutdown()

graphite-client's People

Contributors

stephenpcg avatar

Watchers

 avatar  avatar

Forkers

bingyulei007

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.