Documentation
¶
Overview ¶
Package datadog includes helpers for interacting with datadog.
Index ¶
- Constants
- func ConvertEvent(e stats.Event) *statsd.Event
- type Collector
- func (dc *Collector) AddDefaultTag(key, value string)
- func (dc *Collector) Count(name string, value int64, tags ...string) error
- func (dc *Collector) CreateEvent(title, text string, tags ...string) stats.Event
- func (dc *Collector) DefaultTags() []string
- func (dc *Collector) Gauge(name string, value float64, tags ...string) error
- func (dc *Collector) Histogram(name string, value float64, tags ...string) error
- func (dc *Collector) Increment(name string, tags ...string) error
- func (dc *Collector) SendEvent(event stats.Event) error
- func (dc *Collector) SimpleEvent(title, text string) error
- func (dc *Collector) TimeInMilliseconds(name string, value time.Duration, tags ...string) error
- type Config
- func (c Config) GetBufferDepth(defaults ...int) int
- func (c Config) GetBuffered(defaults ...bool) bool
- func (c Config) GetDefaultTags(defaults ...[]string) []string
- func (c Config) GetHost() string
- func (c Config) GetHostname(defaults ...string) string
- func (c Config) GetNamespace(defaults ...string) string
- func (c Config) GetPort(defaults ...string) string
- func (c Config) GetTraceHost() string
- func (c Config) GetTracePort(defaults ...string) string
- func (c Config) GetTracingEnabled() bool
- func (c Config) IsZero() bool
Constants ¶
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 )
const ( TagService = "service" TagEnv = "env" TagHostname = "hostname" )
Default Tags
const (
// DefaultDatadogBufferDepth is the default number of statsd messages to buffer.
DefaultDatadogBufferDepth = 128
)
Variables ¶
This section is empty.
Functions ¶
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 ¶
NewCollector returns a new stats collector from a config.
func NewCollectorFromEnv ¶
NewCollectorFromEnv returns a new Collector from a config.
func (*Collector) AddDefaultTag ¶
AddDefaultTag adds a new default tag and returns a reference to the collector.
func (*Collector) CreateEvent ¶
CreateEvent makes a new Event with the collectors default tags.
func (*Collector) DefaultTags ¶
DefaultTags returns the default tags for the collector.
func (*Collector) SimpleEvent ¶
SimpleEvent sends an event w/ title and text
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 ¶
NewConfigFromEnv returns a new config from the env.
func (Config) GetBufferDepth ¶
GetBufferDepth returns the buffer depth.
func (Config) GetBuffered ¶
GetBuffered returns if the client should buffer messages or not.
func (Config) GetDefaultTags ¶
GetDefaultTags returns default tags for the client.
func (Config) GetHostname ¶
GetHostname returns the datadog hostname.
func (Config) GetNamespace ¶
GetNamespace returns the default prefix for metric names.
func (Config) GetTraceHost ¶
GetTraceHost returns the datadog trace collector host:port string.
func (Config) GetTracePort ¶
GetTracePort returns the datadog trace port.
func (Config) GetTracingEnabled ¶
GetTracingEnabled returns if tracing is enabled.