metric

package
v0.0.0-...-33ac69c Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2017 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package metric contains code related to service metrics.

Index

Constants

View Source
const CriticalFailurePercentage = 0.5

CriticalFailurePercentage indicates for a replica metric how many measurements are allowed to fail.

Variables

View Source
var (
	// ErrUnknownType indicates that the type is unknown.
	ErrUnknownType = errors.New("metric: unknown type")

	// ErrMetricNotFound indicates that the metric was not found.
	ErrMetricNotFound = errors.New("metric: Metric not found")

	// ErrTooManyFailedMeasurements indicates that too many measurements failed.
	ErrTooManyFailedMeasurements = errors.New("metric: Too many failed measurements")
)

Functions

This section is empty.

Types

type CPUMeasurer

type CPUMeasurer struct {
	ServiceID   string
	ServiceName string
	Metric      Metric
}

CPUMeasurer measures the CPU utilization.

func (*CPUMeasurer) Measure

func (m *CPUMeasurer) Measure(ctx context.Context) (float64, error)

Measure the CPU utilization.

type Goal

type Goal struct {
	Observer *Observer
	Target   Target
}

Goal consist of an observer and a target.

type Kind

type Kind string

Kind represents some kind of metric.

const (
	// KindReplica is a replica metric.
	KindReplica Kind = "replica"

	// KindSystem is a system metric.
	KindSystem Kind = "system"
)

type Measurer

type Measurer interface {
	Measure(ctx context.Context) (float64, error)
}

Measurer measures a metric for a given service.

func NewMeasurer

func NewMeasurer(serviceID, serviceName string, metric Metric) (measurer Measurer, err error)

NewMeasurer creates the right measurer for given metric.

type MemoryMeasurer

type MemoryMeasurer struct {
	ServiceID   string
	ServiceName string
	Metric      Metric
}

MemoryMeasurer measures the memory utilization.

func (*MemoryMeasurer) Measure

func (m *MemoryMeasurer) Measure(ctx context.Context) (float64, error)

Measure the memory utilization.

type Metric

type Metric struct {
	// ID of the metric.
	ID string
	// Name of the metric.
	Name string
	// Type of the metric.
	Type Type
	// Kind of the metric.
	Kind Kind
	// Prometheus spec.
	Prometheus PrometheusSpec
}

Metric represents a service metric.

func New

func New(name string) Metric

New creates a new metric.

type Observer

type Observer struct {
	startstopper.StartStopper

	Measurer          Measurer
	Reducer           reducer.Reducer
	Period            time.Duration
	AggregationAmount uint8
	// contains filtered or unexported fields
}

Observer observes one metric and aggregate measurements.

func NewObserver

func NewObserver(m Measurer, r reducer.Reducer) *Observer

NewObserver creates a new Observer for given measurer and reducer.

func (*Observer) AggregatedMetric

func (o *Observer) AggregatedMetric() (float64, error)

AggregatedMetric of current measurements.

type PrometheusMeasurer

type PrometheusMeasurer struct {
	ServiceID   string
	ServiceName string
	Metric      Metric
	// contains filtered or unexported fields
}

PrometheusMeasurer measures the Prometheus metric.

func (*PrometheusMeasurer) Measure

func (m *PrometheusMeasurer) Measure(ctx context.Context) (float64, error)

Measure the Prometheus metric.

type PrometheusSpec

type PrometheusSpec struct {
	// Endpoint of the Prometheus metrics.
	Endpoint url.URL
	// Name of the Prometheus metrics.
	Name string
}

PrometheusSpec specifies a Prometheus metric.

type Target

type Target struct {
	// Value of the target.
	Value float64

	// UpperDeviation allowed from the target.
	UpperDeviation float64

	// LowerDeviation allowed from the target.
	LowerDeviation float64
}

Target represents a target.

type Type

type Type string

Type represents some category of metrics.

const (
	// TypeCPU is a CPU metric.
	TypeCPU Type = "cpu"

	// TypeMemory is a memory metric.
	TypeMemory Type = "memory"

	// TypePrometheus is a Prometheus metric.
	TypePrometheus Type = "prometheus"
)

Jump to

Keyboard shortcuts

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