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 ¶
- Variables
- func GetMetricKey(metric string, keys ...string) string
- func SetNewSentTimestamp(newTimestamps map[string]float64, key string, ts float64)
- type IntegrationSender
- func (s *IntegrationSender) Commit()
- func (s *IntegrationSender) CountWithTimestampWrapper(name string, value float64, tags []string, ts float64)
- func (s *IntegrationSender) GaugeWithTimestampWrapper(name string, value float64, tags []string, ts float64)
- func (s *IntegrationSender) GetDeviceTags(defaultIPTag string, deviceIP string) []string
- func (s *IntegrationSender) SetDeviceTagsMap(deviceTags map[string][]string)
- func (s *IntegrationSender) ShouldSendEntry(key string, ts float64) bool
- func (s *IntegrationSender) UpdateTimestamps(newTimestamps map[string]float64)
- type Sender
Constants ¶
This section is empty.
Variables ¶
var TimeNow = time.Now
TimeNow useful for mocking
Functions ¶
func GetMetricKey ¶
GetMetricKey returns a metric key for the given metric and keys
Types ¶
type IntegrationSender ¶
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.