datadog

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPort is the default port.
	DefaultPort = "8125"
	// DefaultTracePort is the default trace port.
	DefaultTracePort = "8126"
	// DefaultTracingEnabled is the default value for tracing enabled.
	DefaultTracingEnabled = true
)
View Source
const (
	// DefaultDatadogBufferDepth is the default number of statsd messages to buffer.
	DefaultDatadogBufferDepth = 128
)

Variables

This section is empty.

Functions

func ConvertEvent

func ConvertEvent(e stats.Event) *statsd.Event

ConvertEvent converts a stats event to a statsd (datadog) event.

Types

type Collector

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

Collector is a class that wraps the statsd collector we're using.

func NewCollector

func NewCollector(cfg *Config) (*Collector, error)

NewCollector returns a new stats collector from a config.

func NewCollectorFromEnv

func NewCollectorFromEnv() (*Collector, error)

NewCollectorFromEnv returns a new Collector from a config.

func (*Collector) AddDefaultTag

func (dc *Collector) AddDefaultTag(key, value string)

AddDefaultTag adds a new default tag and returns a reference to the collector.

func (*Collector) Count

func (dc *Collector) Count(name string, value int64, tags ...string) error

Count increments a counter by a value.

func (*Collector) CreateEvent

func (dc *Collector) CreateEvent(title, text string, tags ...string) stats.Event

CreateEvent makes a new Event with the collectors default tags.

func (*Collector) DefaultTags

func (dc *Collector) DefaultTags() []string

DefaultTags returns the default tags for the collector.

func (*Collector) Gauge

func (dc *Collector) Gauge(name string, value float64, tags ...string) error

Gauge sets a gauge value.

func (*Collector) Histogram

func (dc *Collector) Histogram(name string, value float64, tags ...string) error

Histogram sets a guage value.

func (*Collector) Increment

func (dc *Collector) Increment(name string, tags ...string) error

Increment increments a counter by 1.

func (*Collector) SendEvent

func (dc *Collector) SendEvent(event stats.Event) error

SendEvent sends any *statsd.Event

func (*Collector) SimpleEvent

func (dc *Collector) SimpleEvent(title, text string) error

SimpleEvent sends an event w/ title and text

func (*Collector) TimeInMilliseconds

func (dc *Collector) TimeInMilliseconds(name string, value time.Duration, tags ...string) error

TimeInMilliseconds sets a timing value.

type Config

type Config struct {
	// Hostname is the dns name or ip of the datadog collector.
	Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty" env:"DATADOG_HOSTNAME"`
	// Port is the port of the datadog collector.
	Port string `json:"port,omitempty" yaml:"port,omitempty" env:"DATADOG_PORT"`
	// TracePort is the port of the datadog apm collector.
	TracePort string `json:"tracePort,omitempty" yaml:"tracePort,omitempty" env:"DATADOG_TRACE_PORT"`
	// TracingEnabled returns if we should use tracing or not.
	TracingEnabled *bool `json:"tracingEnabled" yaml:"tracingEnabled" env:"DATADOG_APM_ENABLED"`
	// Buffered indicates if we should buffer statsd messages or not.
	Buffered *bool `json:"buffered,omitempty" yaml:"buffered,omitempty" env:"DATADOG_BUFFERED"`
	// BufferDepth is the depth of the buffer for datadog events.
	// A zero value implies an unbuffered client.
	BufferDepth int `json:"bufferDepth,omitempty" yaml:"bufferDepth,omitempty" env:"DATADOG_BUFFER_DEPTH"`
	// Namespace is an optional namespace.
	Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty" env:"DATADOG_NAMESPACE"`
	// DefaultTags are the default tags associated with any stat metric.
	DefaultTags []string `json:"defaultTags,omitempty" yaml:"defaultTags,omitempty" env:"DATADOG_TAGS,csv"`
}

Config is the datadog config.

func MustNewConfigFromEnv

func MustNewConfigFromEnv() (config *Config)

MustNewConfigFromEnv creates a new config from the environment and panics on error.

func NewConfigFromEnv

func NewConfigFromEnv() (*Config, error)

NewConfigFromEnv returns a new config from the env.

func (Config) GetBufferDepth

func (c Config) GetBufferDepth(defaults ...int) int

GetBufferDepth returns the buffer depth.

func (Config) GetBuffered

func (c Config) GetBuffered(defaults ...bool) bool

GetBuffered returns if the client should buffer messages or not.

func (Config) GetDefaultTags

func (c Config) GetDefaultTags(defaults ...[]string) []string

GetDefaultTags returns default tags for the client.

func (Config) GetHost

func (c Config) GetHost() string

GetHost returns the datadog collector host:port string.

func (Config) GetHostname

func (c Config) GetHostname(defaults ...string) string

GetHostname returns the datadog hostname.

func (Config) GetNamespace

func (c Config) GetNamespace(defaults ...string) string

GetNamespace returns the default prefix for metric names.

func (Config) GetPort

func (c Config) GetPort(defaults ...string) string

GetPort returns the datadog port.

func (Config) GetTraceHost

func (c Config) GetTraceHost() string

GetTraceHost returns the datadog trace collector host:port string.

func (Config) GetTracePort

func (c Config) GetTracePort(defaults ...string) string

GetTracePort returns the datadog trace port.

func (Config) GetTracingEnabled added in v0.3.0

func (c Config) GetTracingEnabled() bool

GetTracingEnabled returns if tracing is enabled.

func (Config) IsZero

func (c Config) IsZero() bool

IsZero returns if the config is unset.

Jump to

Keyboard shortcuts

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