metrics

package
v0.11.9 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package metrics provides Etre metrics.

Index

Constants

View Source
const (
	Query                byte = iota // counter (group and system)
	SetOp                            // counter
	Labels                           // histogram
	LatencyMs                        // histogram
	MissSLA                          // counter
	Read                             // counter
	ReadQuery                        // counter
	ReadId                           // counter
	ReadMatch                        // histogram
	ReadLabels                       // counter
	Write                            // counter
	CreateOne                        // counter
	CreateMany                       // counter
	CreateBulk                       // histogram
	UpdateId                         // counter
	UpdateQuery                      // counter
	UpdateBulk                       // histogram
	DeleteId                         // counter
	DeleteQuery                      // counter
	DeleteBulk                       // histogram
	DeleteLabel                      // counter
	LabelRead                        // counter (per-label)
	LabelUpdate                      // counter (per-label)
	LabelDelete                      // counter (per-label)
	DbError                          // counter (global)
	APIError                         // counter (global)
	ClientError                      // counter (global)
	CDCClients                       // counter (global)
	Created                          // counter
	Updated                          // counter
	Deleted                          // counter
	AuthenticationFailed             // counter (system)
	AuthorizationFailed              // counter
	InvalidEntityType                // counter
	QueryTimeout                     // counter
	Load                             // gauge   (system)
	Error                            // counter (system)
)

See ../metrics.go for docs of each metric. The number/order of these does not matter. They are const numbers only to avoid typos and enable compile-time checking, e.g. m.Inc(metrics.Reed, 1) will cause error "undefined: metrics.Reed". Implementations of Metrics must ensure that metric X = etre.MetricReport.X.

Variables

This section is empty.

Functions

func NewGroupEntityMetrics added in v0.9.2

func NewGroupEntityMetrics(gm *groupMetrics) *groupEntityMetrics

func NewGroupMetrics added in v0.9.2

func NewGroupMetrics() *groupMetrics

func NewSystemMetrics added in v0.9.2

func NewSystemMetrics() *systemMetrics

Types

type Factory

type Factory interface {
	Make(groupNames []string) Metrics
}

type Group

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

Group is a one-to-many proxy for setting metrics in multiple metric groups. Group implements the Metrics inteface. The API uses a single Group for all the auth.Caller.MetricGroups. The API can make a single call to Inc(), for example, and Group calls Inc() for every metric group.

func (Group) EntityType

func (gm Group) EntityType(entityType string)

func (Group) Inc

func (gm Group) Inc(mn byte, n int64)

func (Group) IncLabel

func (gm Group) IncLabel(mn byte, label string)

func (Group) Report

func (gm Group) Report(reset bool) etre.Metrics

func (Group) Trace

func (gm Group) Trace(trace map[string]string)

func (Group) Val

func (gm Group) Val(mn byte, n int64)

type GroupFactory

type GroupFactory struct {
	Store Store
}

GroupFactory implements Factory to make Group metrics in the API.

func (GroupFactory) Make

func (f GroupFactory) Make(groupNames []string) Metrics

type Metrics

type Metrics interface {
	// EntityType binds the Metrics instance to an entity type before calling
	// other methods. This method must be called first.
	//
	// The caller is responsible for validating the entity type.
	//
	// This is only valid for group metrics.
	EntityType(string)

	// Inc increments the metric name (mn) by n. The metric must be a counter.
	Inc(mn byte, n int64)

	// IncLabel increments the metric name (mn) counter for the label by 1.
	// The metric must be LabelRead, LabelUpdate, or LabelDelete.
	//
	// This is only valid for group metrics.
	IncLabel(mn byte, label string)

	// Val records one measurement (n) for the metric name (mn). The metric
	// must be a gauge.
	Val(mn byte, n int64)

	// Trace increments trace value counters by 1.
	Trace(map[string]string)

	// Report returns a snapshot of all metrics, calculating stats like average
	// and percentiles.
	Report(reset bool) etre.Metrics
}

Metrics abstracts how metrics are stored and sampled.

func NewGroup

func NewGroup(groupNames []string, store Store) Metrics

type Store

type Store interface {
	Add(m Metrics, name string) error
	Get(name string) Metrics
	Names() []string
}

func NewMemoryStore

func NewMemoryStore() Store

Jump to

Keyboard shortcuts

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