metrics

package
v4.27.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OptSetNowFn

func OptSetNowFn(fn func() time.Time) func(*Tracker)

OptSetNowFn sets the function used to obtain a new time value representing now. By default time.Now is used.

Types

type Observed

type Observed struct {
	Input     map[string]ObservedInput     `json:"input"`
	Processor map[string]ObservedProcessor `json:"processor"`
	Output    map[string]ObservedOutput    `json:"output"`
}

Observed is a subset of typical Benthos metrics collected by streams that we're interested in for studios purposes.

type ObservedInput

type ObservedInput struct {
	Received int64 `json:"received"`
}

ObservedInput is a subset of input metrics that we're interested in.

type ObservedOutput

type ObservedOutput struct {
	Sent  int64 `json:"sent"`
	Error int64 `json:"error"`
}

ObservedOutput is a subset of output metrics that we're interested in.

type ObservedProcessor

type ObservedProcessor struct {
	Received int64 `json:"received"`
	Sent     int64 `json:"sent"`
	Error    int64 `json:"error"`
}

ObservedProcessor is a subset of processor metrics that we're interested in.

type Tracker

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

Tracker keeps a reference to observed metrics and is capable of flushing the currently observed counters. This also implements the internal metrics type as it's used as a drop-in replacement in order to gather those observed counters.

func NewTracker

func NewTracker(opts ...func(t *Tracker)) *Tracker

NewTracker returns a metrics implementation that records studio specific metrics information.

func (*Tracker) Close

func (t *Tracker) Close() error

Close stops aggregating stats and cleans up resources.

func (*Tracker) Flush

func (t *Tracker) Flush() *Observed

Flush the latest observed metrics and reset all counters for the next epoch.

func (*Tracker) GetCounter

func (t *Tracker) GetCounter(name string) metrics.StatCounter

GetCounter returns an editable counter stat for a given path.

func (*Tracker) GetCounterVec

func (t *Tracker) GetCounterVec(name string, labelNames ...string) metrics.StatCounterVec

GetCounterVec returns an editable counter stat for a given path with labels, these labels must be consistent with any other metrics registered on the same path.

func (*Tracker) GetGauge

func (t *Tracker) GetGauge(name string) metrics.StatGauge

GetGauge returns an editable gauge stat for a given path.

func (*Tracker) GetGaugeVec

func (t *Tracker) GetGaugeVec(name string, labelNames ...string) metrics.StatGaugeVec

GetGaugeVec returns an editable gauge stat for a given path with labels, these labels must be consistent with any other metrics registered on the same path.

func (*Tracker) GetTimer

func (t *Tracker) GetTimer(name string) metrics.StatTimer

GetTimer returns an editable timer stat for a given path.

func (*Tracker) GetTimerVec

func (t *Tracker) GetTimerVec(name string, labelNames ...string) metrics.StatTimerVec

GetTimerVec returns an editable timer stat for a given path with labels, these labels must be consistent with any other metrics registered on the same path.

func (*Tracker) HandlerFunc

func (t *Tracker) HandlerFunc() http.HandlerFunc

HandlerFunc returns an optional HTTP request handler that exposes metrics from the implementation. If nil is returned then no endpoint will be registered.

func (*Tracker) LastFlushed

func (t *Tracker) LastFlushed() time.Time

LastFlushed returns the time at which the metrics were last flushed.

Jump to

Keyboard shortcuts

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