Documentation ¶
Index ¶
Constants ¶
const NoOrigin = ""
NoOrigin is returned if origin detection is off or failed.
Variables ¶
This section is empty.
Functions ¶
func InitTelemetry ¶
func InitTelemetry(buckets []float64)
InitTelemetry initialize the telemetry.Histogram buckets for the internal telemetry. This will be called once the first dogstatsd server is created since we need the configuration to be fully loaded.
Types ¶
type Assembler ¶
Assembler merges multiple incoming datagrams into one "Packet" object to save space and make number of message in a single "Packet" more predictable
func NewAssembler ¶
func NewAssembler(flushTimer time.Duration, packetsBuffer *Buffer, sharedPacketPoolManager *PoolManager, packetSourceType SourceType) *Assembler
NewAssembler creates a new Assembler instance using the specified flush duration, buffer and pool manager
func (*Assembler) AddMessage ¶
AddMessage adds a new dogstatsd message to the buffer
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is a buffer of packets that will automatically flush to the given output channel when it is full or after a configurable duration.
type Packet ¶
type Packet struct { Contents []byte // Contents, might contain several messages Buffer []byte // Underlying buffer for data read Origin string // Origin container if identified Source SourceType // Type of listener that produced the packet }
Packet represents a statsd packet ready to process, with its origin metadata if applicable.
As the Packet object is reused in a sync.Pool, we keep the underlying buffer reference to avoid re-sizing the slice before reading
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool wraps the sync.Pool class for *Packet type. It allows to avoid allocating one object per packet.
Caution: as objects get reused, byte slices extracted from packet.Contents will change when the object is reused. You need to hold on to the object until you extracted all the information and parsed it into strings/float/int.
Strings extracted with `string(Contents[n:m]) don't share the origin []byte storage, so they will be unaffected.
type PoolManager ¶
PoolManager helps manage sync pools so multiple references to the same pool objects may be held.
func NewPoolManager ¶
func NewPoolManager(gp genericPool) *PoolManager
NewPoolManager creates a PoolManager to manage the underlying genericPool.
func (*PoolManager) Count ¶
func (p *PoolManager) Count() int
Count returns the number of elements accounted by the PoolManager.
func (*PoolManager) Flush ¶
func (p *PoolManager) Flush()
Flush flushes all objects back to the object pool, and stops tracking any pending objects.
func (*PoolManager) IsPassthru ¶
func (p *PoolManager) IsPassthru() bool
IsPassthru returns a boolean telling us if the PoolManager is in passthru mode or not.
func (*PoolManager) Put ¶
func (p *PoolManager) Put(x interface{})
Put declares intent to return an object to the pool. In passthru mode the object is immediately returned to the pool, otherwise we wait until the object is put by all (only 2 currently supported) reference holders before actually returning it to the object pool.
func (*PoolManager) SetPassthru ¶
func (p *PoolManager) SetPassthru(b bool)
SetPassthru sets the passthru mode to the specified value. It will flush the sccounting before enabling passthru mode.
type SourceType ¶
type SourceType int
SourceType is the type of listener
const ( // UDP listener UDP SourceType = iota // UDS listener UDS // NamedPipe Windows named pipe listner NamedPipe )