metrics

package
v0.73.0-preview.2 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Gauge ...
	Gauge instrument = iota
	// Counter ...
	Counter
	// Histogram ...
	Histogram
	// Summary ...
	Summary
)

Variables

View Source
var (
	// ErrInstrumentNotSupported signals the specified instrument is not yet supported.
	ErrInstrumentNotSupported = errors.New("instrument type unsupported")
	// ErrInstrumentTypeMismatch signal the type of the instrument is not expected.
	ErrInstrumentTypeMismatch = errors.New("instrument is not of the expected type")
)

Functions

func APIRequestAndTimeGraphQL

func APIRequestAndTimeGraphQL(request string, time float64)

APIRequestAndTimeGraphQL updates the metrics for GraphQL API calls.

func APIRequestAndTimeREST

func APIRequestAndTimeREST(method, request string, time float64)

APIRequestAndTimeREST updates the metrics for REST API calls.

func AddBlockHandlingTime

func AddBlockHandlingTime(duration time.Duration)

func BatcherFlushedEntitiesAdd added in v0.71.0

func BatcherFlushedEntitiesAdd(table string, flushed int)

func BlockCounterInc

func BlockCounterInc(labelValues ...string)

func EventBufferReadCountInc added in v0.61.0

func EventBufferReadCountInc()

func EventBufferWrittenCountInc added in v0.61.0

func EventBufferWrittenCountInc()

func EventBusPublishedEventsAdd

func EventBusPublishedEventsAdd(event string, eventCount float64)

func EventCounterInc

func EventCounterInc(labelValues ...string)

func IncrementBatcherAddedEntities added in v0.71.0

func IncrementBatcherAddedEntities(table string)

func NetworkHistoryRowsCopied added in v0.70.0

func NetworkHistoryRowsCopied(table string, rowsCopied int64)

func PublishedEventsAdd

func PublishedEventsAdd(event string, eventCount float64)

func SetBlockHeight

func SetBlockHeight(height float64)

func SetLastSnapshotCurrentStateBytes added in v0.57.0

func SetLastSnapshotCurrentStateBytes(bytes float64)

func SetLastSnapshotHistoryBytes added in v0.57.0

func SetLastSnapshotHistoryBytes(bytes float64)

func SetLastSnapshotRowcount added in v0.57.0

func SetLastSnapshotRowcount(count float64)

func SetLastSnapshotSeconds added in v0.57.0

func SetLastSnapshotSeconds(seconds float64)

func SetNetworkHistoryIpfsStoreBytes added in v0.67.0

func SetNetworkHistoryIpfsStoreBytes(bytes float64)

func Start

func Start(conf Config)

Start enable metrics (given config).

func StartAPIRequestAndTimeGRPC

func StartAPIRequestAndTimeGRPC(request string) func()

StartAPIRequestAndTimeGRPC updates the metrics for GRPC API calls.

func StartActiveEventBusConnection

func StartActiveEventBusConnection() func()

func StartActiveSubscriptionCountGRPC

func StartActiveSubscriptionCountGRPC(subscribedToType string) func()

func StartEventBusActiveSubscriptionCount

func StartEventBusActiveSubscriptionCount(eventTypes []events.Type)

func StartNetworkHistoryCopy added in v0.70.0

func StartNetworkHistoryCopy(table string) func()

func StartSQLQuery

func StartSQLQuery(store string, query string) func()

func StopEventBusActiveSubscriptionCount

func StopEventBusActiveSubscriptionCount(eventTypes []events.Type)

Types

type Config

type Config struct {
	Level   encoding.LogLevel `description:" " long:"log-level"`
	Timeout encoding.Duration `description:" " long:"timeout"`
	Port    int               `description:" " long:"port"`
	Path    string            `description:" " long:"path"`
	Enabled encoding.Bool     `description:" " long:"enabled"`
}

Config represents the configuration of the metric package.

func NewDefaultConfig

func NewDefaultConfig() Config

NewDefaultConfig creates an instance of the package specific configuration, given a pointer to a logger instance to be used for logging within the package.

type InstrumentOption

type InstrumentOption func(o *instrumentOpts)

InstrumentOption - vararg for instrument options setting.

func AgeBuckets

func AgeBuckets(ab uint32) InstrumentOption

AgeBuckets - specific to summary type.

func Buckets

func Buckets(b []float64) InstrumentOption

Buckets - specific to histogram type.

func BufCap

func BufCap(bc uint32) InstrumentOption

BufCap - specific to summary type.

func Help

func Help(help string) InstrumentOption

Help - set the help field on instrument.

func Labels

func Labels(labels map[string]string) InstrumentOption

Labels set labels for instrument (similar to vector, but with given values).

func MaxAge

func MaxAge(m time.Duration) InstrumentOption

MaxAge - specific to summary type.

func Namespace

func Namespace(ns string) InstrumentOption

Namespace - set namespace.

func Objectives

func Objectives(obj map[float64]float64) InstrumentOption

Objectives - specific to summary type.

func Subsystem

func Subsystem(s string) InstrumentOption

Subsystem - set subsystem... obviously.

func Vectors

func Vectors(labels ...string) InstrumentOption

Vectors - configuration used to create a vector of a given interface, slice of label names.

type MetricInstrument

type MetricInstrument interface {
	Gauge() (prometheus.Gauge, error)
	GaugeVec() (*prometheus.GaugeVec, error)
	Counter() (prometheus.Counter, error)
	CounterVec() (*prometheus.CounterVec, error)
	Histogram() (prometheus.Histogram, error)
	HistogramVec() (*prometheus.HistogramVec, error)
	Summary() (prometheus.Summary, error)
	SummaryVec() (*prometheus.SummaryVec, error)
}

MetricInstrument - template interface for mi type return value - only mock if needed, and only mock the funcs you use.

type TimeCounter

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

TimeCounter holds a time.Time and a list of label values, hiding the start time from being accidentally overwritten, and removing the need to duplicate the label values.

func NewTimeCounter

func NewTimeCounter(labelValues ...string) *TimeCounter

NewTimeCounter returns a new TimeCounter, with the start time already recorded.

func (*TimeCounter) EngineTimeCounterAdd

func (tc *TimeCounter) EngineTimeCounterAdd()

EngineTimeCounterAdd is used to time a function. e.g.

func DoSomething() {
	timer := metrics.NewTimeCounter("x", "y", "z")
	// do something
	timer.EngineTimeCounterAdd()
}

func (*TimeCounter) EventTimeCounterAdd

func (tc *TimeCounter) EventTimeCounterAdd()

func (*TimeCounter) FlushTimeCounterAdd

func (tc *TimeCounter) FlushTimeCounterAdd()

func (*TimeCounter) SQLQueryTimeCounterAdd

func (tc *TimeCounter) SQLQueryTimeCounterAdd()

Jump to

Keyboard shortcuts

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