metrics

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

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

Config ... Metrics server configuration

type CountMap added in v1.6.0

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

CountMap ... In memory representation of a prometheus Count metric type

func NewCountMap added in v1.6.0

func NewCountMap() *CountMap

NewCountMap ... Init

func (*CountMap) Get added in v1.6.0

func (cm *CountMap) Get(labels ...string) (uint64, error)

Get ... fetches the value count associated with a deterministic label key

type EmulatedMetricer added in v1.6.0

type EmulatedMetricer struct {
	HTTPServerRequestsTotal *CountMap
	// secondary metrics
	SecondaryRequestsTotal *CountMap
}

EmulatedMetricer ... allows for tracking count metrics in memory and is only used for E2E testing. This is needed since prometheus/client_golang doesn't provide an interface for reading the count values from the codified metric.

func NewEmulatedMetricer added in v1.6.0

func NewEmulatedMetricer() *EmulatedMetricer

NewEmulatedMetricer ... constructor

func (*EmulatedMetricer) Document added in v1.6.0

func (n *EmulatedMetricer) Document() []metrics.DocumentedMetric

Document ... noop

func (*EmulatedMetricer) RecordInfo added in v1.6.0

func (n *EmulatedMetricer) RecordInfo(_ string)

RecordInfo ... noop

func (*EmulatedMetricer) RecordRPCServerRequest added in v1.6.0

func (n *EmulatedMetricer) RecordRPCServerRequest(method string) func(status, mode, ver string)

RecordRPCServerRequest ... updates server requests counter associated with label fingerprint

func (*EmulatedMetricer) RecordSecondaryRequest added in v1.6.0

func (n *EmulatedMetricer) RecordSecondaryRequest(x string, y string) func(status string)

RecordSecondaryRequest ... updates secondary insertion counter associated with label fingerprint

func (*EmulatedMetricer) RecordUp added in v1.6.0

func (n *EmulatedMetricer) RecordUp()

RecordUp ... noop

type Metricer

type Metricer interface {
	RecordInfo(version string)
	RecordUp()

	RecordRPCServerRequest(method string) func(status string, mode string, ver string)
	RecordSecondaryRequest(bt string, method string) func(status string)

	Document() []metrics.DocumentedMetric
}

Metricer ... Interface for metrics

var NoopMetrics Metricer = new(noopMetricer)

type Metrics

type Metrics struct {
	Info *prometheus.GaugeVec
	Up   prometheus.Gauge

	// server metrics
	HTTPServerRequestsTotal          *prometheus.CounterVec
	HTTPServerBadRequestHeader       *prometheus.CounterVec
	HTTPServerRequestDurationSeconds *prometheus.HistogramVec

	// secondary metrics
	SecondaryRequestsTotal      *prometheus.CounterVec
	SecondaryRequestDurationSec *prometheus.HistogramVec
	// contains filtered or unexported fields
}

Metrics ... Metrics struct

func NewMetrics

func NewMetrics(subsystem string) *Metrics

func (*Metrics) Document

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

func (*Metrics) RecordInfo

func (m *Metrics) RecordInfo(version string)

RecordInfo sets a pseudo-metric that contains versioning and config info for the proxy DA node.

func (*Metrics) RecordRPCServerRequest added in v1.4.1

func (m *Metrics) RecordRPCServerRequest(method string) func(status, mode, ver string)

RecordRPCServerRequest is a helper method to record an incoming HTTP request. It bumps the requests metric, and tracks how long it takes to serve a response, including the HTTP status code.

func (*Metrics) RecordSecondaryRequest added in v1.6.0

func (m *Metrics) RecordSecondaryRequest(bt string, method string) func(status string)

RecordSecondaryPut records a secondary put/get operation.

func (*Metrics) RecordUp

func (m *Metrics) RecordUp()

RecordUp sets the up metric to 1.

func (*Metrics) StartServer

func (m *Metrics) StartServer(hostname string, port int) (*ophttp.HTTPServer, error)

StartServer starts the metrics server on the given hostname and port. If port is 0, it automatically assigns an available port and returns the actual port.

Jump to

Keyboard shortcuts

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