juju: github.com/juju/juju/worker/metrics/spool Index | Files

package spool

import "github.com/juju/juju/worker/metrics/spool"

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

Package Files

listener.go manifold.go metrics.go

Constants

const (
    // DefaultTimeout specifies the default socket read and write timeout.
    DefaultTimeout = 3 * time.Second
)

func APIMetricBatch Uses

func APIMetricBatch(batch MetricBatch) params.MetricBatchParam

APIMetricBatch converts the specified MetricBatch to a params.MetricBatch, which can then be sent to the controller.

func IsMetricsDataError Uses

func IsMetricsDataError(err error) bool

IsMetricsDataError returns true if the error cause is errMetricsData.

func Manifold Uses

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold returns a dependency.Manifold that extracts the metrics spool directory path from the agent.

func NewPeriodicWorker Uses

func NewPeriodicWorker(do jworker.PeriodicWorkerCall, period time.Duration, newTimer func(time.Duration) jworker.PeriodicTimer, stop func()) worker.Worker

NewPeriodicWorker returns a periodic worker, that will call a stop function when it is killed.

func NewSocketListener Uses

func NewSocketListener(socketPath string, handler ConnectionHandler) (*socketListener, error)

NewSocketListener returns a new socket listener struct.

type ConnectionHandler Uses

type ConnectionHandler interface {
    Handle(net.Conn, <-chan struct{}) error
}

ConnectionHandler defines the method needed to handle socket connections.

type JSONMetricReader Uses

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

JSONMetricsReader reads metrics batches stored in the spool directory.

func NewJSONMetricReader Uses

func NewJSONMetricReader(spoolDir string) (*JSONMetricReader, error)

NewJSONMetricsReader creates a new JSON metrics reader for the specified spool directory.

func (*JSONMetricReader) Close Uses

func (r *JSONMetricReader) Close() error

Close implements the MetricsReader interface.

func (*JSONMetricReader) Read Uses

func (r *JSONMetricReader) Read() (_ []MetricBatch, err 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 Uses

func (r *JSONMetricReader) Remove(uuid string) error

Remove implements the MetricsReader interface.

type JSONMetricRecorder Uses

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 Uses

func NewJSONMetricRecorder(config MetricRecorderConfig) (rec *JSONMetricRecorder, rErr error)

NewJSONMetricRecorder creates a new JSON metrics recorder.

func (*JSONMetricRecorder) AddMetric Uses

func (m *JSONMetricRecorder) AddMetric(
    key, value string, created time.Time, labels map[string]string) (err error)

AddMetric implements the MetricsRecorder interface.

func (*JSONMetricRecorder) Close Uses

func (m *JSONMetricRecorder) Close() error

Close implements the MetricsRecorder interface.

func (*JSONMetricRecorder) IsDeclaredMetric Uses

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 Uses

type ManifoldConfig engine.AgentManifoldConfig

ManifoldConfig specifies names a spooldirectory manifold should use to address its dependencies.

type MetricBatch Uses

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 Uses

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 Uses

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 Uses

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 Uses

type MetricRecorder interface {
    // AddMetric records a metric with the specified key, value, create time
    // and labels to a spool directory.
    AddMetric(key, value string, created time.Time, labels map[string]string) 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.

type MetricRecorderConfig Uses

type MetricRecorderConfig struct {
    SpoolDir string
    Metrics  map[string]corecharm.Metric
    CharmURL string
    UnitTag  string
}

MetricRecorderConfig stores configuration data for a metrics recorder.

Package spool imports 23 packages (graph) and is imported by 31 packages. Updated 2019-08-22. Refresh now. Tools for package owners.