metrics

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 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 (
	SubsystemHeuristics = "heuristics"
	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 {
	IncActiveHeuristics(ht core.HeuristicType, 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)
	RecordHeuristicRun(heuristic heuristic.Heuristic)
	RecordAlertGenerated(alert core.Alert, dest core.AlertDestination, clientName string)
	RecordNodeError(network core.Network)
	RecordPipelineLatency(pUUID core.PUUID, latency float64)
	RecordAssessmentError(h heuristic.Heuristic)
	RecordInvExecutionTime(h heuristic.Heuristic, 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
	ActiveHeuristics *prometheus.GaugeVec
	HeuristicRuns    *prometheus.CounterVec
	AlertsGenerated  *prometheus.CounterVec
	NodeErrors       *prometheus.CounterVec
	BlockLatency     *prometheus.GaugeVec
	PipelineLatency  *prometheus.GaugeVec
	InvExecutionTime *prometheus.GaugeVec
	HeuristicErrors  *prometheus.CounterVec
	// contains filtered or unexported fields
}

func (*Metrics) DecActivePipelines

func (m *Metrics) DecActivePipelines(pt core.PipelineType, n 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) IncActiveHeuristics added in v1.0.0

func (m *Metrics) IncActiveHeuristics(ht core.HeuristicType, n core.Network,
	pipelineType core.PipelineType)

IncActiveHeuristics ... Increments the number of active heuristics

func (*Metrics) IncActivePipelines

func (m *Metrics) IncActivePipelines(pt core.PipelineType, n core.Network)

IncActivePipelines ... Increments the number of active pipelines

func (*Metrics) RecordAlertGenerated

func (m *Metrics) RecordAlertGenerated(alert core.Alert, dest core.AlertDestination, clientName string)

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

func (*Metrics) RecordAssessmentError added in v1.0.0

func (m *Metrics) RecordAssessmentError(h heuristic.Heuristic)

RecordAssessmentError ... Increments the number of errors generated by heuristic executions

func (*Metrics) RecordBlockLatency

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

RecordBlockLatency ... Records the latency of block processing

func (*Metrics) RecordHeuristicRun added in v1.0.0

func (m *Metrics) RecordHeuristicRun(h heuristic.Heuristic)

RecordHeuristicRun ... Records that a given heuristic has been run

func (*Metrics) RecordInvExecutionTime

func (m *Metrics) RecordInvExecutionTime(h heuristic.Heuristic, latency float64)

RecordInvExecutionTime ... Records the time it took to execute a heuristic

func (*Metrics) RecordNodeError

func (m *Metrics) RecordNodeError(n 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