metrics

package module
v1.2.51 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 12 Imported by: 41

README

Ziti Metrics Library

This is a metrics library which is built on, and extends the go-metrics library.

It extends it by adding the following:

  1. Support for interval counters. These collect event counts related to a given identifier, over a given interval. The interval buckets are flushed regularly. These are good for things like collecting usage data.
  2. A Dispose method is defined on metrics, so they can be cleaned up, for metrics tied to transient entities.
  3. Reference counted metrics

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetIntervalAgeThreshold added in v1.2.9

func SetIntervalAgeThreshold(i time.Duration)

Types

type Gauge

type Gauge interface {
	metrics.Gauge
	Metric
}

Gauge represents a metric which is measuring a count and a rate

type Handler

type Handler interface {
	// AcceptMetrics is called when new metrics become available
	AcceptMetrics(message *metrics_pb.MetricsMessage)
}

Handler represents a sink for metric events

type Histogram

type Histogram interface {
	Metric
	Clear()
	Update(int64)
}

Histogram represents a metric which is measuring the distribution of values for some measurement

type IntervalCounter

type IntervalCounter interface {
	Metric
	Update(intervalId string, time time.Time, value uint64)
}

IntervalCounter allows tracking counters which are bucketized by some interval

type Meter

type Meter interface {
	Metric
	Mark(int64)
}

Meter represents a metric which is measuring a count and a rate

type Metric

type Metric interface {
	Dispose()
}

Metric is the base functionality for all metrics types

type Registry

type Registry interface {
	// SourceId returns the source id of this Registry
	SourceId() string

	// Gauge returns a Gauge for the given name. If one does not yet exist, one will be created
	Gauge(name string) Gauge

	// FuncGauge returns a Gauge for the given name. If one does not yet exist, one will be created using
	// the given function
	FuncGauge(name string, f func() int64) Gauge

	// Meter returns a Meter for the given name. If one does not yet exist, one will be created
	Meter(name string) Meter

	// Histogram returns a Histogram for the given name. If one does not yet exist, one will be created
	Histogram(name string) Histogram

	// Timer returns a Timer for the given name. If one does not yet exist, one will be created
	Timer(name string) Timer

	// EachMetric calls the given visitor function for each Metric in this registry
	EachMetric(visitor func(name string, metric Metric))

	// GetGauge returns the Gauge for the given name or nil if a Gauge with that name doesn't exist
	GetGauge(name string) Gauge

	// GetMeter returns the Meter for the given name or nil if a Meter with that name doesn't exist
	GetMeter(name string) Meter

	// GetHistogram returns the Histogram for the given name or nil if a Histogram with that name doesn't exist
	GetHistogram(name string) Histogram

	// GetTimer returns the Timer for the given name or nil if a Timer with that name doesn't exist
	GetTimer(name string) Timer

	// IsValidMetric returns true if a metric with the given name exists in the registry, false otherwise
	IsValidMetric(name string) bool

	// Poll returns a MetricsMessage with a snapshot of the metrics in the Registry
	Poll() *metrics_pb.MetricsMessage

	// DisposeAll removes and cleans up all metrics currently in the Registry
	DisposeAll()
}

Registry allows for configuring and accessing metrics for an application

func NewRegistry

func NewRegistry(sourceId string, tags map[string]string) Registry

type Timer

type Timer interface {
	Metric
	Time(func())
	Update(time.Duration)
	UpdateSince(time.Time)
}

type UsageCounter added in v1.1.0

type UsageCounter interface {
	Metric
	Update(source UsageSource, usageType string, time time.Time, value uint64)
}

A UsageCounter allows tracking usage bucketized by some interval

type UsageRegistry

type UsageRegistry interface {
	Registry
	PollWithoutUsageMetrics() *metrics_pb.MetricsMessage
	IntervalCounter(name string, intervalSize time.Duration) IntervalCounter
	UsageCounter(name string, intervalSize time.Duration) UsageCounter
	FlushToHandler(handler Handler)
	StartReporting(eventSink Handler, reportInterval time.Duration, msgQueueSize int)
}

UsageRegistry extends registry to allow collecting usage metrics

func NewUsageRegistry

func NewUsageRegistry(sourceId string, tags map[string]string, closeNotify <-chan struct{}) UsageRegistry

type UsageSource added in v1.1.0

type UsageSource interface {
	GetIntervalId() string
	GetTags() map[string]string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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