listeners

package
v0.0.0-...-fbc319c Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

README

package listeners

This package handles the network transmission for statsd protocols and returns packets to be processed by the dogstatsd package.

Packet

Packet is a statsd packet that might contain several statsd messages in it's Contents field. If origin detection is supported and enabled, the Origin field will hold the container id ready for tag resolution. If not, the field holds an empty string.

StatsdListener

StatsdListener is the common interface, currently implemented by:

  • UDPListener: handles the historical UDP protocol,
  • UDSDatagramListener: handles the host-local UDS protocol with optional origin detection, see the doc for more info.
  • UDSStreamListener: handles the host-local UDS protocol with optional origin detection, using a stream based protocol.

Origin Detection is Linux only

As our client implementations rely on Unix Credentials being added automatically by the Linux kernel, this feature is Linux only for now. If needed, server and client side could be updated and tested with other unices.

Documentation

Overview

Package listeners implements the StatsdListener interfaces.

Index

Constants

View Source
const RandomPortName = "__random__" // this would be zero if zero wasn't used already to disable udp support.

RandomPortName is the value for dogstatsd_port setting that indicates that the server should allocate a random unique port.

Variables

This section is empty.

Functions

func NewUDSOobPoolManager

func NewUDSOobPoolManager() *packets.PoolManager[[]byte]

NewUDSOobPoolManager returns an UDS OOB pool manager

Types

type CloseFunction

type CloseFunction func(unixConn netUnixConn) error

CloseFunction is a function that closes a connection

type ConnectionTracker

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

ConnectionTracker tracks connections and closes them gracefully.

func NewConnectionTracker

func NewConnectionTracker(name string, closeDelay time.Duration) *ConnectionTracker

NewConnectionTracker creates a new ConnectionTracker. closeDelay is the time to wait before closing a connection. First it will be shutdown for write, which will notify the client that we are disconnecting, then it will be closed. This gives some time to consume the remaining packets.

func (*ConnectionTracker) Close

func (t *ConnectionTracker) Close(conn net.Conn)

Close closes a connection.

func (*ConnectionTracker) HandleConnections

func (t *ConnectionTracker) HandleConnections()

HandleConnections handles connections.

func (*ConnectionTracker) Start

func (t *ConnectionTracker) Start()

Start starts the connection tracker.

func (*ConnectionTracker) Stop

func (t *ConnectionTracker) Stop()

Stop stops the connection tracker. To be called one the listener is stopped, after the server socket has been close.

func (*ConnectionTracker) Track

func (t *ConnectionTracker) Track(conn net.Conn)

Track tracks a connection.

type NamedPipeListener

type NamedPipeListener struct{}

NamedPipeListener implements the StatsdListener interface for named pipe protocol.

func NewNamedPipeListener

NewNamedPipeListener returns an named pipe Statsd listener

func (*NamedPipeListener) Listen

func (l *NamedPipeListener) Listen()

Listen runs the intake loop. Should be called in its own goroutine

func (*NamedPipeListener) Stop

func (l *NamedPipeListener) Stop()

Stop closes the connection and stops listening

type StatsdListener

type StatsdListener interface {
	Listen()
	Stop()
}

StatsdListener opens a communication channel to get statsd packets in.

type TelemetryStore

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

TelemetryStore holds all the telemetry counters and gauges for the dogstatsd listeners

func NewTelemetryStore

func NewTelemetryStore(buckets []float64, telemetrycomp telemetry.Component) *TelemetryStore

NewTelemetryStore returns a new TelemetryStore

type UDPListener

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

UDPListener implements the StatsdListener interface for UDP protocol. It listens to a given UDP address and sends back packets ready to be processed. Origin detection is not implemented for UDP.

func NewUDPListener

func NewUDPListener(packetOut chan packets.Packets, sharedPacketPoolManager *packets.PoolManager[packets.Packet], cfg model.Reader, capture replay.Component, telemetryStore *TelemetryStore, packetsTelemetryStore *packets.TelemetryStore) (*UDPListener, error)

NewUDPListener returns an idle UDP Statsd listener

func (*UDPListener) Listen

func (l *UDPListener) Listen()

Listen runs the intake loop. Should be called in its own goroutine

func (*UDPListener) LocalAddr

func (l *UDPListener) LocalAddr() string

LocalAddr returns the local network address of the listener.

func (*UDPListener) Stop

func (l *UDPListener) Stop()

Stop closes the UDP connection and stops listening

type UDSDatagramListener

type UDSDatagramListener struct {
	UDSListener
	// contains filtered or unexported fields
}

UDSDatagramListener implements the StatsdListener interface for Unix Domain (datagrams)

func NewUDSDatagramListener

func NewUDSDatagramListener(packetOut chan packets.Packets, sharedPacketPoolManager *packets.PoolManager[packets.Packet], sharedOobPoolManager *packets.PoolManager[[]byte], cfg model.Reader, capture replay.Component, wmeta optional.Option[workloadmeta.Component], pidMap pidmap.Component, telemetryStore *TelemetryStore, packetsTelemetryStore *packets.TelemetryStore, telemetryComponent telemetry.Component) (*UDSDatagramListener, error)

NewUDSDatagramListener returns an idle UDS datagram Statsd listener

func (*UDSDatagramListener) Listen

func (l *UDSDatagramListener) Listen()

Listen runs the intake loop. Should be called in its own goroutine

func (*UDSDatagramListener) Stop

func (l *UDSDatagramListener) Stop()

Stop closes the UDS connection and stops listening

type UDSListener

type UDSListener struct {
	OriginDetection bool
	// contains filtered or unexported fields
}

UDSListener implements the StatsdListener interface for Unix Domain Socket datagram protocol. It listens to a given socket path and sends back packets ready to be processed. Origin detection will be implemented for UDS.

func NewUDSListener

func NewUDSListener(packetOut chan packets.Packets, sharedPacketPoolManager *packets.PoolManager[packets.Packet], sharedOobPacketPoolManager *packets.PoolManager[[]byte], cfg model.Reader, capture replay.Component, transport string, wmeta optional.Option[workloadmeta.Component], pidMap pidmap.Component, telemetryStore *TelemetryStore, packetsTelemetryStore *packets.TelemetryStore, telemetry telemetry.Component) (*UDSListener, error)

NewUDSListener returns an idle UDS Statsd listener

func (*UDSListener) Stop

func (l *UDSListener) Stop()

Stop closes the UDS connection and stops listening

type UDSStreamListener

type UDSStreamListener struct {
	UDSListener
	// contains filtered or unexported fields
}

UDSStreamListener implements the StatsdListener interface for Unix Domain (streams)

func NewUDSStreamListener

func NewUDSStreamListener(packetOut chan packets.Packets, sharedPacketPoolManager *packets.PoolManager[packets.Packet], sharedOobPacketPoolManager *packets.PoolManager[[]byte], cfg model.Reader, capture replay.Component, wmeta optional.Option[workloadmeta.Component], pidMap pidmap.Component, telemetryStore *TelemetryStore, packetsTelemetryStore *packets.TelemetryStore, telemetry telemetry.Component) (*UDSStreamListener, error)

NewUDSStreamListener returns an idle UDS datagram Statsd listener

func (*UDSStreamListener) Listen

func (l *UDSStreamListener) Listen()

Listen runs the intake loop. Should be called in its own goroutine

func (*UDSStreamListener) Stop

func (l *UDSStreamListener) Stop()

Stop closes the UDS connection and stops listening

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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