metrics

package
v2.16.19 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: Apache-2.0, Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package metrics defines a set of basic building blocks for instrumenting the gateway.

Check the sibling "gin" and "mux" packages for complete implementations.

Index

Constants

View Source
const Namespace = "github_com/devopsfaith/krakend-metrics"

Namespace is the key to look for extra configuration details

Variables

This section is empty.

Functions

func ConfigGetter

func ConfigGetter(e config.ExtraConfig) interface{}

ConfigGetter implements the config.ConfigGetter interface. It parses the extra config for the collectors and returns a defaultCfg if something goes wrong.

func NewDummyRegistry

func NewDummyRegistry() metrics.Registry

func NewProxyMiddleware

func NewProxyMiddleware(layer, name string, pm *ProxyMetrics) proxy.Middleware

NewProxyMiddleware creates a proxy middleware ready to be injected in the pipe as instrumentation point

Types

type Config

type Config struct {
	ProxyDisabled    bool
	RouterDisabled   bool
	BackendDisabled  bool
	CollectionTime   time.Duration
	ListenAddr       string
	EndpointDisabled bool
}

Config holds if a component is active or not

type DummyRegistry

type DummyRegistry struct{}

DummyRegistry implements the rcrowley/go-metrics.Registry interface

func (DummyRegistry) Each

func (DummyRegistry) Each(_ func(string, interface{}))

func (DummyRegistry) Get

func (DummyRegistry) Get(_ string) interface{}

func (DummyRegistry) GetAll

func (DummyRegistry) GetAll() map[string]map[string]interface{}

func (DummyRegistry) GetOrRegister

func (DummyRegistry) GetOrRegister(_ string, i interface{}) interface{}

func (DummyRegistry) Register

func (DummyRegistry) Register(_ string, _ interface{}) error

func (DummyRegistry) RunHealthchecks

func (DummyRegistry) RunHealthchecks()

func (DummyRegistry) Unregister

func (DummyRegistry) Unregister(_ string)

func (DummyRegistry) UnregisterAll

func (DummyRegistry) UnregisterAll()

type HistogramData

type HistogramData struct {
	Max         int64
	Min         int64
	Mean        float64
	Stddev      float64
	Variance    float64
	Percentiles []float64
}

HistogramData is a snapshot of an actual histogram

type Metrics

type Metrics struct {
	// Config is the metrics collector configuration
	Config *Config
	// Proxy is the metrics collector for the proxy package
	Proxy *ProxyMetrics
	// Router is the metrics collector for the router package
	Router *RouterMetrics
	// Registry is the metrics register
	Registry *metrics.Registry
	// contains filtered or unexported fields
}

Metrics is the component that manages all the metrics

func New

New creates a new metrics producer

func (*Metrics) BackendFactory

func (m *Metrics) BackendFactory(segmentName string, next proxy.BackendFactory) proxy.BackendFactory

BackendFactory creates an instrumented backend factory

func (*Metrics) DefaultBackendFactory

func (m *Metrics) DefaultBackendFactory() proxy.BackendFactory

DefaultBackendFactory creates an instrumented default HTTP backend factory

func (*Metrics) NewProxyMiddleware

func (m *Metrics) NewProxyMiddleware(layer, name string) proxy.Middleware

NewProxyMiddleware creates a proxy middleware ready to be injected in the pipe as instrumentation point

func (*Metrics) ProxyFactory

func (m *Metrics) ProxyFactory(segmentName string, next proxy.Factory) proxy.FactoryFunc

ProxyFactory creates an instrumented proxy factory

func (*Metrics) Snapshot

func (m *Metrics) Snapshot() Stats

Snapshot returns the last calculted snapshot

func (*Metrics) TakeSnapshot

func (m *Metrics) TakeSnapshot() Stats

TakeSnapshot takes a snapshot of the current state

type ProxyMetrics

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

ProxyMetrics is the metrics collector for the proxy package

func NewProxyMetrics

func NewProxyMetrics(parent *metrics.Registry) *ProxyMetrics

NewProxyMetrics creates a ProxyMetrics using the injected registry

func (*ProxyMetrics) Counter

func (rm *ProxyMetrics) Counter(labels ...string) metrics.Counter

Counter gets or register a counter

func (*ProxyMetrics) Histogram

func (rm *ProxyMetrics) Histogram(labels ...string) metrics.Histogram

Histogram gets or register a histogram

type RouterMetrics

type RouterMetrics struct {
	ProxyMetrics
	// contains filtered or unexported fields
}

RouterMetrics is the metrics collector for the router package

func NewRouterMetrics

func NewRouterMetrics(parent *metrics.Registry) *RouterMetrics

NewRouterMetrics creates a RouterMetrics using the injected registry

func (*RouterMetrics) Aggregate

func (rm *RouterMetrics) Aggregate()

func (*RouterMetrics) Connection

func (rm *RouterMetrics) Connection(TLS *tls.ConnectionState)

Connection adds one to the internal connected counter

func (*RouterMetrics) Disconnection

func (rm *RouterMetrics) Disconnection()

Disconnection adds one to the internal disconnected counter

func (*RouterMetrics) RegisterResponseWriterMetrics

func (rm *RouterMetrics) RegisterResponseWriterMetrics(name string)

type Stats

type Stats struct {
	Time       int64
	Counters   map[string]int64
	Gauges     map[string]int64
	Histograms map[string]HistogramData
}

Stats represents a snapshot of the collected metrics

func NewStats

func NewStats() Stats

NewStats instantiates a stats struct

Directories

Path Synopsis
Package gin defines a set of basic building blocks for instrumenting KrakenD gateways built using the gin router
Package gin defines a set of basic building blocks for instrumenting KrakenD gateways built using the gin router
Package mux defines a set of basic building blocks for instrumenting KrakenD gateways built using the mux router
Package mux defines a set of basic building blocks for instrumenting KrakenD gateways built using the mux router

Jump to

Keyboard shortcuts

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