carbon

package module
v0.0.0-...-68d8280 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2016 License: MIT Imports: 3 Imported by: 1

README

carbon-golang

What is carbon-golang?

A Go-based library written to make it easier to send Carbon metrics to a Carbon cache.

How do I use it?

From your binary,

import (
    "github.com/jforman/carbon-golang"
)

package main

func main() {
    var string carbonHost
    var int carbonPort
    var bool carbonNoop
    var bool carbonVerbose
    carbonReceiver, err := carbon.NewCarbon(carbonHost, carbonPort, carbonNoop, carbonVerbose)
    metrics := []carbon.Metric
    metrics := append(metrics, carbon.Metric{Name: "foo.bar.min", Value: 2, Timestamp: 1234567890})
    metrics := append(metrics, carbon.Metric{Name: "foo.bar.max", Value: 10, Timestamp: 1234567890})
    carbonReciever.SendMetrics(metrics)
}

Or in shot: Create an instance of a carbon receiver, make a list of metrics, and send the metrics in.

What's next?

I plan to refactor the code to make it more correct, and add helper functions to make sending metrics in even more straightforward and easy.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Carbon

type Carbon struct {
	Host    string
	Port    int
	Timeout time.Duration

	Noop     bool
	Protocol string
	Verbose  bool
	// contains filtered or unexported fields
}

func NewCarbon

func NewCarbon(host string, port int, noop bool, verbose bool) (*Carbon, error)

Create new Carbon object as well as connect to Carbon instance.

func (*Carbon) Connect

func (carbon *Carbon) Connect() error

func (*Carbon) IsDefined

func (carbon *Carbon) IsDefined() bool

Is a Carbon Host defined? In other words, do we intend to send to carbon?

func (*Carbon) IsNoop

func (carbon *Carbon) IsNoop() bool

func (*Carbon) SendMetric

func (carbon *Carbon) SendMetric(metric Metric) error

Given a carbon Metric, send it to Carbon.

func (*Carbon) SendMetrics

func (carbon *Carbon) SendMetrics(metrics []Metric) error

Given a list of metrics, send them each invidually.

type Metric

type Metric struct {
	Name      string
	Value     float64
	Timestamp int64
}

func (Metric) String

func (metric Metric) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL