Documentation ¶
Overview ¶
Package datadog includes helpers for interacting with datadog.
Index ¶
- Constants
- func ConvertEvent(e stats.Event) *dogstatsd.Event
- func NewTracer(opts ...TracerOption) opentracing.Tracer
- func UseProfiler(cfg Config) bool
- func UseTracing(cfg Config) bool
- type Collector
- func (dc *Collector) AddDefaultTag(name, value string)
- func (dc *Collector) AddDefaultTags(tags ...string)
- func (dc *Collector) Close() error
- 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) Distribution(name string, value float64, tags ...string) error
- func (dc *Collector) Flush() error
- 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) BufferDepthOrDefault() int
- func (c Config) BufferedOrDefault() bool
- func (c Config) GetAddress() string
- func (c Config) GetProfilerAddress() string
- func (c Config) GetTraceAddress() string
- func (c Config) IsZero() bool
- func (c Config) PortOrDefault() string
- func (c Config) ProfilingEnabledOrDefault() bool
- func (c *Config) Resolve(ctx context.Context) error
- func (c Config) TracePortOrDefault() string
- func (c Config) TraceSampleRateOrDefault() float64
- func (c Config) TracingEnabledOrDefault() bool
- type RateSampler
- type TracerOption
- func OptTraceAgentAddr(addr string) TracerOption
- func OptTraceConfig(cfg Config) TracerOption
- func OptTraceHostname(hostname string) TracerOption
- func OptTraceLog(log logger.Triggerable) TracerOption
- func OptTraceSampleRate(rate float64) TracerOption
- func OptTraceServiceEnv(serviceEnv string) TracerOption
- func OptTraceServiceName(serviceName string) TracerOption
- func OptTraceVersion(version string) TracerOption
- type TracerOptions
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 // DefaultProfilingEnabled is the default value for profiling enabled. DefaultProfilingEnabled = true // DefaultTraceSampleRate returns the default trace sample rate of 25% DefaultTraceSampleRate = 0.25 // DefaultAddress is the default address for datadog. DefaultAddress = "unix:///var/run/datadog/dsd.socket" )
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 ¶
func ConvertEvent ¶
ConvertEvent converts a stats event to a statsd (datadog) event.
func NewTracer ¶
func NewTracer(opts ...TracerOption) opentracing.Tracer
NewTracer returns a new tracer.
It defaults to the service environment as named by the `SERVICE_ENV` environment variable. It defaults the sample rate to the sample rate as returned by the configuration.
func UseProfiler ¶ added in v1.20210103.1
UseProfiler returns if profiling is enabled and the profiler address is configured.
It should be used to gate if you should create a profiler with `profiler.Start`.
func UseTracing ¶
UseTracing returns if tracing is enabled and the trace address is configured.
It should be used to gate if you should create tracers with `NewTracer`.
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector is a class that wraps the statsd collector we're using.
func (*Collector) AddDefaultTag ¶
AddDefaultTag adds a new default tag.
func (*Collector) AddDefaultTags ¶
AddDefaultTags adds new default tags.
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) Distribution ¶ added in v1.20210103.1
Distribution sets a gauge value that statistics are computed on the server.
func (*Collector) Histogram ¶
Histogram sets a gauge value that statistics are computed on the agent.
func (*Collector) SimpleEvent ¶
SimpleEvent sends an event w/ title and text
type Config ¶
type Config struct { // Address is the address of the datadog collector in the form of "hostname:port" or "unix:///path/to/socket" // It will supercede `Hostname` and `Port`. Address string `json:"address,omitempty" yaml:"address,omitempty" env:"DATADOG_ADDRESS"` // TraceAddress is the address of the datadog collector in the form of "hostname:port" or "unix:///path/to/trace-socket" // It will supercede `TraceHostname` and `TracePort` TraceAddress string `json:"traceAddress,omitempty" yaml:"traceAddress,omitempty" env:"DATADOG_TRACE_ADDRESS"` // ProfilerAddress is the address of the datadog collector in the form of "hostname:port" or "unix:///path/to/profiler-socket" ProfilerAddress string `json:"profilerAddress,omitempty" yaml:"profilerAddress,omitempty" env:"DATADOG_PROFILER_ADDRESS"` // Hostname is the host portion of a <host>:<port> address. It will be used in conjunction with `Port` // to form the default `Address`. Hostname string `json:"hostname,omitempty" yaml:"hostname,omitempty" env:"DATADOG_HOSTNAME"` // Port is the port portion of a <host>:<port> address. It will be used in conjunction with `Host` // to form the default `Address`. Port string `json:"port,omitempty" yaml:"port,omitempty" env:"DATADOG_PORT"` // TraceHostname is the host portion of a <host>:<port> address. It will be used in conjunction with `TracePort` // to form the default `TraceAddress`. TraceHostname string `json:"traceHostname,omitempty" yaml:"traceHostname,omitempty" env:"DATADOG_TRACE_HOSTNAME"` // TracePort is the port portion of a <host>:<port> address. It will be used in conjunction with `TraceHost` // to form the default `TraceAddress`. 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,omitempty" yaml:"tracingEnabled,omitempty" env:"DATADOG_APM_ENABLED"` // TracingSampleRate is the default tracing sample rate, on the interval [0-1] TraceSampleRate *float64 `json:"traceSampleRate,omitempty" yaml:"traceSampleRate,omitempty" env:"DATADOG_APM_SAMPLE_RATE"` // ProfilingEnabled returns if we should use profiling or not. ProfilingEnabled *bool `json:"profilingEnabled,omitempty" yaml:"profilingEnabled,omitempty" env:"DATADOG_PROFILING_ENABLED"` // Buffered indicates if we should buffer statsd metrics. Buffered *bool `json:"buffered,omitempty" yaml:"buffered,omitempty" env:"DATADOG_BUFFERED"` // BufferDepth is the depth of the buffer for statsd metrics. BufferDepth int `json:"bufferDepth,omitempty" yaml:"bufferDepth,omitempty" env:"DATADOG_BUFFER_DEPTH"` // Namespace is an optional namespace. // The namespace is a prefix on all statsd metric names submitted to the collector. 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_DEFAULT_TAGS,csv"` }
Config is the datadog config.
func (Config) BufferDepthOrDefault ¶
BufferDepthOrDefault returns the buffer depth.
func (Config) BufferedOrDefault ¶
BufferedOrDefault returns if the client should buffer messages or not.
func (Config) GetAddress ¶
GetAddress returns the datadog collector address string.
func (Config) GetProfilerAddress ¶ added in v1.20210103.1
GetProfilerAddress gets the profiler address.
func (Config) GetTraceAddress ¶
GetTraceAddress returns the datadog collector address string.
func (Config) PortOrDefault ¶
PortOrDefault returns the port or a default.
func (Config) ProfilingEnabledOrDefault ¶ added in v1.20210103.1
ProfilingEnabledOrDefault returns if tracing is enabled.
func (Config) TracePortOrDefault ¶
TracePortOrDefault returns the trace port or a default.
func (Config) TraceSampleRateOrDefault ¶
TraceSampleRateOrDefault returns the trace sample rate or a default.
func (Config) TracingEnabledOrDefault ¶
TracingEnabledOrDefault returns if tracing is enabled.
type RateSampler ¶
type RateSampler float64
RateSampler samples from a sample rate.
type TracerOption ¶ added in v1.20210103.1
type TracerOption func(*TracerOptions)
TracerOption mutates tracer options
func OptTraceAgentAddr ¶ added in v1.20210103.1
func OptTraceAgentAddr(addr string) TracerOption
OptTraceAgentAddr returns a dd tracer start option that sets the agent addr.
func OptTraceConfig ¶ added in v1.20210103.1
func OptTraceConfig(cfg Config) TracerOption
OptTraceConfig sets relevant fields from the datadog config.
func OptTraceHostname ¶ added in v1.20210103.1
func OptTraceHostname(hostname string) TracerOption
OptTraceHostname returns a dd tracer start option that sets the service hostname.
func OptTraceLog ¶ added in v1.20210103.1
func OptTraceLog(log logger.Triggerable) TracerOption
OptTraceLog returns an option that sets the log output.
func OptTraceSampleRate ¶
func OptTraceSampleRate(rate float64) TracerOption
OptTraceSampleRate returns a dd tracer start option that sets trace sampler with a given rate.
func OptTraceServiceEnv ¶
func OptTraceServiceEnv(serviceEnv string) TracerOption
OptTraceServiceEnv returns a dd tracer start option that sets the service environment.
func OptTraceServiceName ¶ added in v1.20210103.1
func OptTraceServiceName(serviceName string) TracerOption
OptTraceServiceName returns a dd tracer start option that sets the service.
func OptTraceVersion ¶ added in v1.20210103.1
func OptTraceVersion(version string) TracerOption
OptTraceVersion returns a dd tracer start option that sets the service version.
type TracerOptions ¶ added in v1.20210103.1
type TracerOptions struct { Addr string StatsAddr string ServiceName string ServiceEnv string Version string Hostname string SampleRate float64 Tags map[string]string Log logger.Triggerable }
TracerOptions are all the options we can set when creating a tracer.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package traceserver is a mocked APM trace server that calls a handler for each spanlists payload it gets.
|
Package traceserver is a mocked APM trace server that calls a handler for each spanlists payload it gets. |