metrics

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SummaryType   = "summary"
	HistogramType = "histogram"
	GaugeType     = "gauge"
	CounterType   = "counter"
)
View Source
const (
	SubsystemInvariants = "invariants"
	SubsystemEtl        = "etl"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host              string
	Port              int
	Enabled           bool
	ReadHeaderTimeout int
}

type DocumentedMetric

type DocumentedMetric struct {
	Type   string   `json:"type"`
	Name   string   `json:"name"`
	Help   string   `json:"help"`
	Labels []string `json:"labels"`
}

type Factory

type Factory interface {
	NewCounter(opts prometheus.CounterOpts) prometheus.Counter
	NewCounterVec(opts prometheus.CounterOpts, labelNames []string) *prometheus.CounterVec
	NewGauge(opts prometheus.GaugeOpts) prometheus.Gauge
	NewGaugeVec(opts prometheus.GaugeOpts, labelNames []string) *prometheus.GaugeVec
	NewHistogram(opts prometheus.HistogramOpts) prometheus.Histogram
	NewHistogramVec(opts prometheus.HistogramOpts, labelNames []string) *prometheus.HistogramVec
	NewSummary(opts prometheus.SummaryOpts) prometheus.Summary
	NewSummaryVec(opts prometheus.SummaryOpts, labelNames []string) *prometheus.SummaryVec
	Document() []DocumentedMetric
}

func With

func With(registry *prometheus.Registry) Factory

type Metricer

type Metricer interface {
	IncActiveInvariants(invType core.InvariantType, network core.Network, pipelineType core.PipelineType)
	IncActivePipelines(pipelineType core.PipelineType, network core.Network)
	DecActivePipelines(pipelineType core.PipelineType, network core.Network)
	RecordBlockLatency(network core.Network, latency float64)
	RecordInvariantRun(invariant invariant.Invariant)
	RecordAlertGenerated(alert core.Alert)
	RecordNodeError(network core.Network)
	RecordPipelineLatency(pUUID core.PUUID, latency float64)
	RecordInvExecutionError(inv invariant.Invariant)
	RecordInvExecutionTime(inv invariant.Invariant, latency float64)
	RecordUp()
	Start()
	Shutdown(ctx context.Context) error
	Document() []DocumentedMetric
}
var NoopMetrics Metricer = new(noopMetricer)

func New

func New(ctx context.Context, cfg *Config) (Metricer, func(), error)

New ... Creates a new metrics server registered with defined custom metrics

func WithContext

func WithContext(ctx context.Context) Metricer

WithContext returns a Metricer from the given context. If no Metricer is found, the default noopMetricer is returned.

type Metrics

type Metrics struct {
	Up               prometheus.Gauge
	ActivePipelines  *prometheus.GaugeVec
	ActiveInvariants *prometheus.GaugeVec
	InvariantRuns    *prometheus.CounterVec
	AlertsGenerated  *prometheus.CounterVec
	NodeErrors       *prometheus.CounterVec
	BlockLatency     *prometheus.GaugeVec
	PipelineLatency  *prometheus.GaugeVec
	InvExecutionTime *prometheus.GaugeVec
	InvariantErrors  *prometheus.CounterVec
	// contains filtered or unexported fields
}

func (*Metrics) DecActivePipelines

func (m *Metrics) DecActivePipelines(pipelineType core.PipelineType, network core.Network)

DecActivePipelines ... Decrements the number of active pipelines

func (*Metrics) Document

func (m *Metrics) Document() []DocumentedMetric

Document ... Returns a list of documented metrics

func (*Metrics) IncActiveInvariants

func (m *Metrics) IncActiveInvariants(invType core.InvariantType, network core.Network,
	pipelineType core.PipelineType)

IncActiveInvariants ... Increments the number of active invariants

func (*Metrics) IncActivePipelines

func (m *Metrics) IncActivePipelines(pipelineType core.PipelineType, network core.Network)

IncActivePipelines ... Increments the number of active pipelines

func (*Metrics) RecordAlertGenerated

func (m *Metrics) RecordAlertGenerated(alert core.Alert)

RecordAlertGenerated ... Records that an alert has been generated for a given invariant

func (*Metrics) RecordBlockLatency

func (m *Metrics) RecordBlockLatency(network core.Network, latency float64)

RecordBlockLatency ... Records the latency of block processing

func (*Metrics) RecordInvExecutionError

func (m *Metrics) RecordInvExecutionError(inv invariant.Invariant)

RecordInvExecutionError ... Increments the number of errors generated by invariant executions

func (*Metrics) RecordInvExecutionTime

func (m *Metrics) RecordInvExecutionTime(inv invariant.Invariant, latency float64)

RecordInvExecutionTime ... Records the time it took to execute an invariant

func (*Metrics) RecordInvariantRun

func (m *Metrics) RecordInvariantRun(inv invariant.Invariant)

RecordInvariantRun ... Records that a given invariant has been run

func (*Metrics) RecordNodeError

func (m *Metrics) RecordNodeError(network core.Network)

RecordNodeError ... Records that an error has been caught for a given node

func (*Metrics) RecordPipelineLatency

func (m *Metrics) RecordPipelineLatency(pUUID core.PUUID, latency float64)

RecordPipelineLatency ... Records the latency of pipeline processing

func (*Metrics) RecordUp

func (m *Metrics) RecordUp()

RecordUp ... Records that the service has been successfully started

func (*Metrics) Shutdown

func (m *Metrics) Shutdown(ctx context.Context) error

Shutdown ... Shuts down the metrics server

func (*Metrics) Start

func (m *Metrics) Start()

Start ... Starts a listen and serve API routine

Jump to

Keyboard shortcuts

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