Documentation ¶
Overview ¶
Package spool contains the implementation of a worker that extracts the spool directory path from the agent config and enables other workers to write and read metrics to and from a the spool directory using a writer and a reader.
Index ¶
- func APIMetricBatch(batch MetricBatch) params.MetricBatchParam
- func Manifold(config ManifoldConfig) dependency.Manifold
- type JSONMetricReader
- type JSONMetricRecorder
- type ManifoldConfig
- type MetricBatch
- type MetricFactory
- type MetricMetadata
- type MetricReader
- type MetricRecorder
- type MetricRecorderConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func APIMetricBatch ¶
func APIMetricBatch(batch MetricBatch) params.MetricBatchParam
APIMetricBatch converts the specified MetricBatch to a params.MetricBatch, which can then be sent to the state server.
func Manifold ¶
func Manifold(config ManifoldConfig) dependency.Manifold
Manifold returns a dependency.Manifold that extracts the metrics spool directory path from the agent.
Types ¶
type JSONMetricReader ¶
type JSONMetricReader struct {
// contains filtered or unexported fields
}
JSONMetricsReader reads metrics batches stored in the spool directory.
func NewJSONMetricReader ¶
func NewJSONMetricReader(spoolDir string) (*JSONMetricReader, error)
NewJSONMetricsReader creates a new JSON metrics reader for the specified spool directory.
func (*JSONMetricReader) Close ¶
func (r *JSONMetricReader) Close() error
Close implements the MetricsReader interface.
func (*JSONMetricReader) Read ¶
func (r *JSONMetricReader) Read() ([]MetricBatch, error)
Read implements the MetricsReader interface. Due to the way the batches are stored in the file system, they will be returned in an arbitrary order. This does not affect the behavior.
func (*JSONMetricReader) Remove ¶
func (r *JSONMetricReader) Remove(uuid string) error
Remove implements the MetricsReader interface.
type JSONMetricRecorder ¶
type JSONMetricRecorder struct {
// contains filtered or unexported fields
}
JSONMetricRecorder implements the MetricsRecorder interface and writes metrics to a spool directory for store-and-forward.
func NewJSONMetricRecorder ¶
func NewJSONMetricRecorder(config MetricRecorderConfig) (rec *JSONMetricRecorder, rErr error)
NewJSONMetricRecorder creates a new JSON metrics recorder.
func (*JSONMetricRecorder) AddMetric ¶
func (m *JSONMetricRecorder) AddMetric(key, value string, created time.Time) error
AddMetric implements the MetricsRecorder interface.
func (*JSONMetricRecorder) Close ¶
func (m *JSONMetricRecorder) Close() error
Close implements the MetricsRecorder interface.
func (*JSONMetricRecorder) IsDeclaredMetric ¶
func (m *JSONMetricRecorder) IsDeclaredMetric(key string) bool
IsDeclaredMetric returns true if the metric recorder is permitted to store this metric. Returns false if the uniter using this recorder doesn't define this metric.
type ManifoldConfig ¶
type ManifoldConfig util.AgentManifoldConfig
ManifoldConfig specifies names a spooldirectory manifold should use to address its dependencies.
type MetricBatch ¶
type MetricBatch struct { CharmURL string `json:"charmurl"` UUID string `json:"uuid"` Created time.Time `json:"created"` Metrics []jujuc.Metric `json:"metrics"` UnitTag string `json:"unit-tag"` }
MetricBatch stores the information relevant to a single metrics batch.
type MetricFactory ¶
type MetricFactory interface { // Recorder returns a new MetricRecorder. Recorder(metrics map[string]corecharm.Metric, charmURL, unitTag string) (MetricRecorder, error) // Reader returns a new MetricReader. Reader() (MetricReader, error) }
MetricFactory contains the metrics reader and recorder factories.
type MetricMetadata ¶
type MetricMetadata struct { CharmURL string `json:"charmurl"` UUID string `json:"uuid"` Created time.Time `json:"created"` UnitTag string `json:"unit-tag"` }
MetricMetadata is used to store metadata for the current metric batch.
type MetricReader ¶
type MetricReader interface { // Read returns all metric batches stored in the spool directory. Read() ([]MetricBatch, error) // Remove removes the metric batch with the specified uuid // from the spool directory. Remove(uuid string) error // Close implements io.Closer. Close() error }
MetricReader reads metrics from a spool directory.
type MetricRecorder ¶
type MetricRecorder interface { // AddMetric records a metric with the specified key, value and create time // to a spool directory. AddMetric(key, value string, created time.Time) error // Close implements io.Closer. Close() error // IsDeclaredMetrics returns true if the metric recorder // is permitted to store metrics with the specified key. IsDeclaredMetric(key string) bool }
MetricRecorder records metrics to a spool directory.