Documentation ¶
Index ¶
Constants ¶
const NoOrigin = ""
NoOrigin is returned if origin detection is off or failed.
const SizeOfPacket = unsafe.Sizeof(Packet{})
SizeOfPacket is the size of a packet structure in bytes
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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[Packet], 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.
func NewBuffer ¶
func NewBuffer(bufferSize uint, flushTimer time.Duration, outputChannel chan Packets, listenerID string, telemetryStore *TelemetryStore) *Buffer
NewBuffer creates a new buffer of packets of specified size
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 ListenerID string // Listener ID 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
func (*Packet) DataSizeInBytes ¶
DataSizeInBytes returns the size of the packet data in bytes
func (*Packet) SizeInBytes ¶
SizeInBytes returns the size of the packet in bytes
type Packets ¶
type Packets []*Packet
Packets is a slice of packet pointers
func (*Packets) DataSizeInBytes ¶
DataSizeInBytes returns the size of the packets data in bytes
func (*Packets) SizeInBytes ¶
SizeInBytes returns the size of the packets in bytes
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.
func NewPool ¶
func NewPool(bufferSize int, packetsTelemetry *TelemetryStore) *Pool
NewPool creates a new pool with a specified buffer size
type PoolManager ¶
type PoolManager[K managedPoolTypes] struct { sync.RWMutex // contains filtered or unexported fields }
PoolManager helps manage sync pools so multiple references to the same pool objects may be held.
func NewPoolManager ¶
func NewPoolManager[K managedPoolTypes](gp genericPool[K]) *PoolManager[K]
NewPoolManager creates a PoolManager to manage the underlying genericPool.
func (*PoolManager[K]) Count ¶
func (p *PoolManager[K]) Count() int
Count returns the number of elements accounted by the PoolManager.
func (*PoolManager[K]) Flush ¶
func (p *PoolManager[K]) Flush()
Flush flushes all objects back to the object pool, and stops tracking any pending objects.
func (*PoolManager[K]) IsPassthru ¶
func (p *PoolManager[K]) IsPassthru() bool
IsPassthru returns a boolean telling us if the PoolManager is in passthru mode or not.
func (*PoolManager[K]) Put ¶
func (p *PoolManager[K]) Put(x *K)
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[K]) SetPassthru ¶
func (p *PoolManager[K]) 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 )
type TelemetryStore ¶
type TelemetryStore struct {
// contains filtered or unexported fields
}
TelemetryStore holds all the telemetry counters and gauges for the dogstatsd packets
func NewTelemetryStore ¶
func NewTelemetryStore(buckets []float64, telemetrycomp telemetry.Component) *TelemetryStore
NewTelemetryStore returns a new TelemetryStore
func (*TelemetryStore) TelemetryTrackPackets ¶
func (t *TelemetryStore) TelemetryTrackPackets(packets Packets, listenerID string)
TelemetryTrackPackets tracks the number of packets in the channel and the number of bytes
func (*TelemetryStore) TelemetryUntrackPackets ¶
func (t *TelemetryStore) TelemetryUntrackPackets(packets Packets)
TelemetryUntrackPackets untracks the number of packets in the channel and the number of bytes