Documentation
¶
Overview ¶
Package metricsender contains functions for sending metrics from a controller to a remote metric collector.
Package metricsender contains functions for sending metrics from a controller to a remote metric collector.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultMaxBatchesPerSend ¶
func DefaultMaxBatchesPerSend() int
DefaultMaxBatchesPerSend returns the default number of batches per send.
func SendMetrics ¶
func SendMetrics(st ModelBackend, sender MetricSender, clock clock.Clock, batchSize int, transmitVendorMetrics bool) error
SendMetrics will send any unsent metrics over the MetricSender interface in batches no larger than batchSize.
func ToWire ¶
func ToWire(mb *state.MetricBatch) *wireformat.MetricBatch
ToWire converts the state.MetricBatch into a type that can be sent over the wire to the collector.
Types ¶
type HTTPSender ¶
type HTTPSender struct {
}
HTTPSender is the default used for sending metrics to the collector service.
func (*HTTPSender) Send ¶
func (s *HTTPSender) Send(metrics []*wireformat.MetricBatch) (*wireformat.Response, error)
Send sends the given metrics to the collector service.
type MetricSender ¶
type MetricSender interface {
Send([]*wireformat.MetricBatch) (*wireformat.Response, error)
}
MetricSender defines the interface used to send metrics to a collection service.
func DefaultMetricSender ¶
func DefaultMetricSender() MetricSender
DefaultMetricSender returns the default metric sender.
type MetricsSenderBackend ¶
type MetricsSenderBackend interface {
MetricsManager() (*state.MetricsManager, error)
MetricsToSend(batchSize int) ([]*state.MetricBatch, error)
SetMetricBatchesSent(batchUUIDs []string) error
CountOfUnsentMetrics() (int, error)
CountOfSentMetrics() (int, error)
}
MetricsSenderBackend defines methods provided by a state instance used by the metrics sender apiserver implementation. All the interface methods are defined directly on state.State and are reproduced here for use in tests.
type ModelBackend ¶
type ModelBackend interface {
MetricsSenderBackend
Unit(name string) (*state.Unit, error)
ModelTag() names.ModelTag
ModelConfig() (*config.Config, error)
}
ModelBackend contains additional methods that are used by the metrics sender.
type NopSender ¶
type NopSender struct {
}
NopSender is a sender that acts like everything worked fine But doesn't do anything.
func (NopSender) Send ¶
func (n NopSender) Send(batches []*wireformat.MetricBatch) (*wireformat.Response, error)
Implement the send interface, act like everything is fine.