metrics

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package metrics implements metrics collection and reporting.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadGetFailedTotal

func ReadGetFailedTotal(gatherer prometheus.Gatherer) (int64, error)

func ReadGetSuccessTotal

func ReadGetSuccessTotal(gatherer prometheus.Gatherer) (int64, error)

func ReadHealthyTotal

func ReadHealthyTotal(gatherer prometheus.Gatherer) (int64, error)

func ReadRegisteredTotal

func ReadRegisteredTotal(gatherer prometheus.Gatherer) (int64, error)

func ReadUnhealthyTotal

func ReadUnhealthyTotal(gatherer prometheus.Gatherer) (int64, error)

func Register

func Register(reg *prometheus.Registry) error

func SetGetFailed

func SetGetFailed(componentName string)

func SetGetSuccess

func SetGetSuccess(componentName string)

func SetHealthy

func SetHealthy(componentName string)

func SetRegistered

func SetRegistered(componentName string)

func SetUnhealthy

func SetUnhealthy(componentName string)

Types

type Averager

type Averager interface {
	// Returns the ID.
	MetricName() string

	// Returns the last value and whether it exists.
	Last(ctx context.Context, opts ...OpOption) (float64, bool, error)

	// Observe the value at the given time and returns the current average.
	// If currentTime is zero, it uses the current system time in UTC.
	Observe(ctx context.Context, value float64, opts ...OpOption) error

	// Avg returns the average value from the "since" time.
	// If since is zero, returns the average value for all data points.
	Avg(ctx context.Context, opts ...OpOption) (float64, error)

	// EMA returns the EMA value from the "since" time.
	// If since is zero, returns the EMA value for all data points.
	// If the ema period is zero, returns the 1-minute EMA value.
	EMA(ctx context.Context, opts ...OpOption) (float64, error)

	// Returns all the data points since the given time.
	// If since is zero, returns all metrics.
	Read(ctx context.Context, opts ...OpOption) (state.Metrics, error)
}

Defines the continuous averager interface.

func NewAverager

func NewAverager(db *sql.DB, tableName string, metricName string) Averager

func NewNoOpAverager

func NewNoOpAverager() Averager

type Op

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

type OpOption

type OpOption func(*Op)

func WithCurrentTime

func WithCurrentTime(t time.Time) OpOption

func WithEMAPeriod

func WithEMAPeriod(period time.Duration) OpOption

func WithMetricSecondaryName

func WithMetricSecondaryName(name string) OpOption

func WithSince

func WithSince(t time.Time) OpOption

Directories

Path Synopsis
Package state provides the persistent storage layer for the metrics.
Package state provides the persistent storage layer for the metrics.

Jump to

Keyboard shortcuts

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