statsd

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TaggingDataDog format
	// Tags are at the end with a preceding #. Tags are colon pairs and comma seperated.
	// Sample rate is optional.
	// As a side note telegraf is capable of digesting both in the same metric. They look for datadog
	// using the preceding # after splitting on a |
	//
	// https://docs.datadoghq.com/developers/dogstatsd/datagram_shell/
	//
	// Example:
	// metric_name:value|type[|sample_rate]|#tag:value,tag:value
	TaggingDataDog = "datadog"

	// TaggingInflux format
	// Influx pushed the tags into the middle of the metrics and have a = key value pair and comma seperated.
	// Sampling is option here.
	//
	// https://www.influxdata.com/blog/getting-started-with-sending-statsd-metrics-to-telegraf-influxdb/
	//
	// Example:
	// metric_name[,tag=value,tag=value]:value|type[|sample_rate]
	TaggingInflux Tagging = "influx"
	// TaggingNone will just drop the tags
	TaggingNone Tagging = "none"

	// MagicTagSampleRate is used to serialize the sample rate on polys
	MagicTagSampleRate = "sample_rate"
	// MagicTagMetricType is used to serialize the metric type on polys
	MagicTagMetricType = "metric_type"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type StatsD

type StatsD struct {
	// contains filtered or unexported fields
}

StatsD is a serializer that will format the measurement into strings with single measurements per line. It is able to format the tags into Influx or DataDogs formatting.

func New

func New(taggingFormat Tagging) *StatsD

New returns a pointer to a StatD serializer that is ready to take measurements

func (*StatsD) Counter

func (sd *StatsD) Counter(m *measurements.Counter) ([]byte, error)

Counter formats counter measurements

func (*StatsD) Gauge

func (sd *StatsD) Gauge(m *measurements.Gauge) ([]byte, error)

Gauge formats Gauge measurements Gauges are special due to a bug... If a gauge was positive and then becomes negative, you first need to set it to zero, then set the value to the negative number. The same the other way around. What this means for us is that we need to track the values of the gauges from the last value. (roll eyes...) This could mean that we need to send 2 statsd measurements for 1 gauge.

func (*StatsD) Poly

func (sd *StatsD) Poly(m *measurements.Poly) ([]byte, error)

Poly formats poly measurements StatsD doesn't really understand the idea of multiple measurements in a single line. Therefore if you want to use a Polymorphic measurement then you need to have only a single type in the measurement. Polymorphic measurements get broken down into multiple statsd lines each containing the values from the provided fields. They still have to be the same type... There are some exceptions, due to interface{} being ANYTHING in go, we only accept certian types and if its not one of them a error is returned a the message is dropped. Consider yourself warned... Magic Tags Because polymorphic measurements don't really translate well into statsd we need to add some hints into the tags to tell the serializer what to do with the measurements. I call these magic tags. They provide the statsd type and sample rate. Below is how they work. The heading is what the tag needs to be. Always lower case.

metric_type Valid values: "gauge", "set", "counter", "timing", "ms", "histogram" Description: Is used to map out the type that is attached to the statsd metric. Required: true

sample_rate Valid values: A float32 as a string. Description: Used in place of the sample rate in the statsd measurement Required: false

func (*StatsD) Timer

func (sd *StatsD) Timer(m *measurements.Timer) ([]byte, error)

Timer formats timer measurements Statsd timers seem to only work with ms. However other platforms work in any value. Therefore if the user wants to make use of statsd then all timers need to be set to precision ms. If it is not it will drop you metrics. (roll eyes...)

type Tagging

type Tagging string

Tagging defines how you would like the tags to be applied to the metric

Jump to

Keyboard shortcuts

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