monitor

package
v1.0.31 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2022 License: MIT Imports: 2 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BrickMetric

type BrickMetric interface{}

BrickMetric is a marker interface

type BricksCounter

type BricksCounter interface {
	BrickMetric
	WithTags(tags map[string]string) (Counter, error)
}

BricksCounter defines a counter to be implemented by external wrapper

type BricksGauge

type BricksGauge interface {
	BrickMetric
	WithTags(tags map[string]string) (Gauge, error)
}

BricksGauge defines a gauge to be implemented by external wrapper

type BricksHistogram

type BricksHistogram interface {
	BrickMetric
	WithTags(tags map[string]string) (Histogram, error)
}

BricksHistogram defines a histogram to be implemented by external wrapper

type BricksMetrics

type BricksMetrics interface {
	// Counter creates a counter with predefined tag key names.
	// This will allow to set their values right before using Counter methods
	Counter(name, desc string, tagKeys ...string) (BricksCounter, error)
	// Gauge creates a gauge with predefined tag key names.
	// This will allow to set their values right before using Gauge methods
	Gauge(name, desc string, tagKeys ...string) (BricksGauge, error)
	// Histogram creates a histogram with predefined tag key names.
	// This will allow to set their values right before using Histogram methods
	Histogram(name, desc string, buckets []float64, tagKeys ...string) (BricksHistogram, error)
	// Timer creates a timer with predefined tag key names.
	// This will allow to set their values right before using Histogram methods
	Timer(name, desc string, tagKeys ...string) (BricksTimer, error)
	// Remove removes this metric from external registry, if applicable
	Remove(metric BrickMetric) error
}

BricksMetrics defines various monitoring capabilities to be implemented by external wrapper

type BricksReporter

type BricksReporter interface {
	// Connect, if applicable connect to the agent only when this function is called
	Connect(ctx context.Context) error
	// Close, if applicable disconnect/close connection to the agent
	Close(ctx context.Context) error
	// Metrics returns implementation of BricksMetrics
	Metrics() BricksMetrics
}

BricksReporter defines Metrics reporter to be implemented by external wrapper

type BricksTimer

type BricksTimer interface {
	BrickMetric
	WithTags(tags map[string]string) (Timer, error)
}

BricksTimer defines a timer to be implemented by external wrapper

type Buckets

type Buckets []float64

Buckets must be ordered in increasing order

type Builder

type Builder interface {
	Build() BricksReporter
}

Builder defines a simple BricksReporter builder

type ContextExtractor

type ContextExtractor func(ctx context.Context) Tags

ContextExtractor is a function that will extract values from the context and return them as Tags Make sure that this function returns fast and is "thread safe"

type Counter

type Counter interface {
	// Inc increments the counter by 1
	Inc()
	// Add adds the given value to the counter, negative values are not advised
	Add(v float64)
}

Counter is a Metric that represents a single numerical value that only ever goes up

type Gauge

type Gauge interface {
	// Set sets Gauge value
	Set(v float64)
	// Add adds (or subtracts if negative) from previously set value
	Add(v float64)
	// Inc adds 1
	Inc()
	// Dec adds -1
	Dec()
}

Gauge is a Metric that represents a single numerical value that can arbitrarily go up and down

type Histogram

type Histogram interface {
	// Record value
	Record(v float64)
}

A Histogram counts individual observations from an event or sample stream in configurable buckets

type Metrics

type Metrics interface {
	// Counter creates or loads a counter with possible predefined tags
	Counter(name, desc string) TagsAwareCounter
	// Gauge creates or loads a gauge with possible predefined tags
	Gauge(name, desc string) TagsAwareGauge
	// Histogram creates or loads a histogram with possible predefined tags
	Histogram(name, desc string, buckets Buckets) TagsAwareHistogram
	// Timer creates or loads a timer with possible predefined tags
	Timer(name, desc string) TagsAwareTimer
	// WithTags sets custom tags to be included if possible in every Metric
	WithTags(tags Tags) Metrics
}

Metrics defines various monitoring capabilities

It is expected that each Metric is unique, uniqueness is calculated by combining

  • name
  • tag key names

Everytime you call to obtain one of the metrics, you will receive an instance. Bricks have an internal cache, hence we are not creating a new metric everytime, unless another set of tags is provided using WithTags. Metric returned from one the methods of this Interface (Metrics) will always have default tag values (if provided)

However if you decide to cache it, your instance will always have it's tags overwritten if WithTags/WithContext called on the instance. To "reset" to default them simply "create" a new one with the same set of tags keys.

type Reporter

type Reporter interface {
	Connect(ctx context.Context) error
	Close(ctx context.Context) error
	Metrics() Metrics
}

Reporter defines Metrics reporter with Connect/Close options on demand and not on creation

type Tags

type Tags map[string]string

Tags or Labels, key->value

type TagsAwareCounter

type TagsAwareCounter interface {
	Counter
	WithTags(tags Tags) TagsAwareCounter
	WithContext(ctx context.Context) TagsAwareCounter
}

TagsAwareCounter defines a counter with the ability override tags value either explicitly or from context (by extractors)

type TagsAwareGauge

type TagsAwareGauge interface {
	Gauge
	WithTags(tags Tags) TagsAwareGauge
	WithContext(ctx context.Context) TagsAwareGauge
}

TagsAwareGauge defines a gauge with the ability to override tags value either explicitly or from context (by extractors)

type TagsAwareHistogram

type TagsAwareHistogram interface {
	Histogram
	WithTags(tags Tags) TagsAwareHistogram
	WithContext(ctx context.Context) TagsAwareHistogram
}

TagsAwareHistogram defines a histogram with the ability to override tags value either explicitly or from context (by extractors)

type TagsAwareTimer

type TagsAwareTimer interface {
	Timer
	WithTags(tags Tags) TagsAwareTimer
	WithContext(ctx context.Context) TagsAwareTimer
}

TagsAwareTimer defines a timer with the ability to override tags value either explicitly or from context (by extractors)

type Timer

type Timer interface {
	Record(d time.Duration)
}

Timer is used to track duration of operations

Directories

Path Synopsis
Package mock_monitor is a generated GoMock package.
Package mock_monitor is a generated GoMock package.

Jump to

Keyboard shortcuts

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