metrics

package
v0.0.0-...-57dc925 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ClockKey is the key associated to a clock.Clock.
	ClockKey = "Clock"
	// NodesMetricsKey is the key associated to a map of node.Metrics.
	NodesMetricsKey = "Nodes"
	// PodsMetricsKey is the key associated to a map of pod.Metrics.
	PodsMetricsKey = "Pods"
	// QueueMetricsKey is the key associated to a queue.Metrics.
	QueueMetricsKey = "Queue"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FileWriter

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

FileWriter is a Writer that writes metrics to a file.

func NewFileWriter

func NewFileWriter(dest string, formatter Formatter) (*FileWriter, error)

NewFileWriter creates a new FileWriter with an output device or file at the given path, and the formatter that formats metrics to a string If /dev/stdout or stdout is given, the standard out is set. If /dev/stderr or stderr is given, the standard error is set. Otherwise, the file of a given path is set and it will be truncated if it exists. Returns error if failed to create a file.

func (*FileWriter) FileName

func (w *FileWriter) FileName() string

FileName returns the name of file underlying this FileWriter.

func (*FileWriter) Write

func (w *FileWriter) Write(metrics *Metrics) error

Write implements Writer interface. Returns error if failed to format with the underlying formatter.

type Formatter

type Formatter interface {
	// Format formats the given metrics to a string.
	Format(metrics *Metrics) (string, error)
}

Formatter defines the interface of metrics formatter.

type HumanReadableFormatter

type HumanReadableFormatter struct{}

HumanReadableFormatter is a Foramtter that formats metrics in a human-readable style.

func (*HumanReadableFormatter) Format

func (h *HumanReadableFormatter) Format(metrics *Metrics) (string, error)

Format implements Formatter interface. Returns error if the given metrics does not have valid structure.

type JSONFormatter

type JSONFormatter struct {
}

JSONFormatter is a Formatter that formats metrics to a JSON string.

func (*JSONFormatter) Format

func (j *JSONFormatter) Format(metrics *Metrics) (string, error)

Format implements Formatter interface. It formats the given metrics to a single JSON string, without newline at the end. Returns error if failed to marshal.

type Metrics

type Metrics map[string]interface{}

Metrics represents a metrics at one time point, in the following structure.

  Metrics[ClockKey] = a formatted clock
  Metrics[NodesMetricsKey] = map from node name to node.Metrics
  Metrics[PodsMetricsKey] = map from pod name to pod.Metrics
	 Metrics[QueueMetricsKey] = queue.Metrics

func BuildMetrics

func BuildMetrics(clock clock.Clock, nodes map[string]*node.Node, queue queue.PodQueue) (Metrics, error)

BuildMetrics builds a Metrics at the given clock.

type TableFormatter

type TableFormatter struct{}

TableFormatter is a Formatter that formats metrics in a table.

func (*TableFormatter) Format

func (t *TableFormatter) Format(metrics *Metrics) (string, error)

Format implements Formatter interface. Returns error if the given metrics does not have valid structure.

type Writer

type Writer interface {
	// Write writes the given metrics to some location(s).
	Write(metrics *Metrics) error
}

Writer defines the interface of metrics writer.

Jump to

Keyboard shortcuts

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