sender

package
v0.0.0-...-bfe00b6 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package sender provides a common interface for sending network device metrics and metadata to the Datadog Agent. It abstracts the underlying sender implementation, allowing for different sender types (e.g., for different network device integrations) to be used interchangeably.

Index

Constants

This section is empty.

Variables

View Source
var TimeNow = time.Now

TimeNow useful for mocking

Functions

func GetMetricKey

func GetMetricKey(metric string, keys ...string) string

GetMetricKey returns a metric key for the given metric and keys

func SetNewSentTimestamp

func SetNewSentTimestamp(newTimestamps map[string]float64, key string, ts float64)

SetNewSentTimestamp is a util to set new timestamps

Types

type IntegrationSender

type IntegrationSender struct {
	sender.Sender
	// contains filtered or unexported fields
}

IntegrationSender implements the Sender interface for network device integrations

func NewSender

func NewSender(sender sender.Sender, integration string, namespace string) *IntegrationSender

NewSender returns a new IntegrationSender

func (*IntegrationSender) Commit

func (s *IntegrationSender) Commit()

Commit commits the current sender state and expires old timestamps

func (*IntegrationSender) CountWithTimestampWrapper

func (s *IntegrationSender) CountWithTimestampWrapper(name string, value float64, tags []string, ts float64)

CountWithTimestampWrapper wraps sender CountWithTimestamp with error handling

func (*IntegrationSender) GaugeWithTimestampWrapper

func (s *IntegrationSender) GaugeWithTimestampWrapper(name string, value float64, tags []string, ts float64)

GaugeWithTimestampWrapper wraps sender GaugeWithTimestamp with error handling

func (*IntegrationSender) GetDeviceTags

func (s *IntegrationSender) GetDeviceTags(defaultIPTag string, deviceIP string) []string

GetDeviceTags returns the device tags for a given IP address If no tags are found, it returns a default tag with the IP address and the configured namespace.

func (*IntegrationSender) SetDeviceTagsMap

func (s *IntegrationSender) SetDeviceTagsMap(deviceTags map[string][]string)

SetDeviceTagsMap sets the device tags map

func (*IntegrationSender) ShouldSendEntry

func (s *IntegrationSender) ShouldSendEntry(key string, ts float64) bool

ShouldSendEntry checks if a metric entry should be sent based on its timestamp It compares the current timestamp with the last sent timestamp for the given key.

func (*IntegrationSender) UpdateTimestamps

func (s *IntegrationSender) UpdateTimestamps(newTimestamps map[string]float64)

UpdateTimestamps updates the last sent timestamps This is used to avoid sending the same metric multiple times within a short period of time.

type Sender

type Sender interface {
	sender.Sender
	// GaugeWithTimestampWrapper wraps sender GaugeWithTimestamp with error handling
	GaugeWithTimestampWrapper(name string, value float64, tags []string, ts float64)
	// CountWithTimestamp wraps sender CountWithTimestamp with error handling
	CountWithTimestampWrapper(name string, value float64, tags []string, ts float64)
	// UpdateTimestamps updates the last sent timestamps
	UpdateTimestamps(newTimestamps map[string]float64)
	// SetDeviceTagsMap sets the device tags map
	SetDeviceTagsMap(deviceTags map[string][]string)
	// GetDeviceTags returns the device tags for a given IP address
	GetDeviceTags(defaultIPTag string, deviceIP string) []string
	// ShouldSendEntry checks if a metric entry should be sent based on its timestamp
	ShouldSendEntry(key string, ts float64) bool
}

Sender interface defines the methods for sending metrics and metadata for network devices. It extends the sender.Sender interface to include additional functionality specific to NDM.

Jump to

Keyboard shortcuts

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