dogstatsd

package
v0.0.2-0...-4ce78c8 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2021 License: Apache-2.0, Apache-2.0 Imports: 25 Imported by: 0

README

package dogstatsd

This package is responsible for receiving metrics from external software over UDP or UDS. Every package has to follow the Dogstatsd format: http://docs.datadoghq.com/guides/dogstatsd/.

Metrics will be sent to the aggregator just like regular metrics from checks. This mean that aggregator and forwarder configuration will also inpact Dogstatsd.

Usage example:

// you must first initialize the aggregator, see aggregator.InitAggregator

// This will return an already running statd server ready to receive metrics
statsd, err := dogstatsd.NewServer(aggregatorInstance.GetBufferedChannels(), nil)

// ...

statsd.Stop()

Dogstatsd implementation documentation (PacketsBuffer, StringInterner, ...) is available in docs/dogstatsd/internals.md.

Details on existing Dogstatsd internals tuning fields are available in docs/dogstatsd/configuration.md.

[Experimental] Dogstatsd protocol 1.1

This feature is experimental for now and could change or be remove in futur release.

Starting with agent 7.25.0/6.25.0 Dogstatsd datagram can contain multiple values using the : delimiter.

For example, this payload contains 3 values (1.5, 20, and 30) for the metric my_metric:

my_metric:1.5:20:30|h|#tag1,tag2

All metric types except set support this, since : could be in the value of a set. Sets are now being aggregated on the client side, so this is not an issue.

Most official Dogstatsd clients now support client-side aggregation for metrics type outside histograms and distributions. This evolution in the protocol allows clients to buffer histogram and distribution values and send them in fewer payload to the agent (providing a behavior close to client-side aggregation for those types).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatDebugStats

func FormatDebugStats(stats []byte) (string, error)

FormatDebugStats returns a printable version of debug stats.

func ScanLines

func ScanLines(data []byte, atEOF bool) (advance int, token []byte, eol bool, err error)

ScanLines is an almost identical reimplementation of bufio.ScanLines, but also reports if the returned line is newline-terminated

Types

type Server

type Server struct {
	Statistics *util.Stats
	Started    bool

	Debug *dsdServerDebug

	// ServerlessMode is set to true if we're running in a serverless environment.
	ServerlessMode     bool
	UdsListenerRunning bool
	// contains filtered or unexported fields
}

Server represent a Dogstatsd server

func NewServer

func NewServer(aggregator *aggregator.BufferedAggregator, extraTags []string) (*Server, error)

NewServer returns a running DogStatsD server. If extraTags is nil, they will be read from DD_DOGSTATSD_TAGS if set.

func (*Server) DisableMetricsStats

func (s *Server) DisableMetricsStats()

DisableMetricsStats disables the debug mode of the DogStatsD server and stops the debug mainloop.

func (*Server) EnableMetricsStats

func (s *Server) EnableMetricsStats()

EnableMetricsStats enables the debug mode of the DogStatsD server and start the debug mainloop collecting the amount of metrics received.

func (*Server) Flush

func (s *Server) Flush()

Flush flushes all the data to the aggregator to them send it to the Datadog intake.

func (*Server) GetJSONDebugStats

func (s *Server) GetJSONDebugStats() ([]byte, error)

GetJSONDebugStats returns jsonified debug statistics.

func (*Server) Stop

func (s *Server) Stop()

Stop stops a running Dogstatsd server

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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