metrics

package
v1.15.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2023 License: GPL-3.0 Imports: 7 Imported by: 7

Documentation

Index

Constants

View Source
const (
	// MetricGroup name format for each user.
	UserMetricGroupFormat = "user - %s"

	UserMetricInBytes  = "InBytes"
	UserMetricOutBytes = "OutBytes"
)

Variables

View Source
var (
	// Max number of connections ever reached.
	MaxConn = RegisterMetric("connections", "MaxConn")

	// Accumulated active open connections.
	ActiveOpens = RegisterMetric("connections", "ActiveOpens")

	// Accumulated passive open connections.
	PassiveOpens = RegisterMetric("connections", "PassiveOpens")

	// Current number of established connections.
	CurrEstablished = RegisterMetric("connections", "CurrEstablished")

	// Number of bytes receive from proxy connections.
	InBytes = RegisterMetric("traffic", "InBytes")

	// Number of bytes send to proxy connections.
	OutBytes = RegisterMetric("traffic", "OutBytes")

	// Number of padding bytes send to proxy connections.
	OutPaddingBytes = RegisterMetric("traffic", "OutPaddingBytes")
)

Functions

func DisableLogging

func DisableLogging()

Disable metrics logging.

func EnableLogging

func EnableLogging()

Enable metrics logging with the given time duration.

func LogMetricsNow added in v1.15.0

func LogMetricsNow()

LogMetricsNow writes the current metrics to log. This function can be called when (periodic) logging is disabled.

func SetLoggingDuration

func SetLoggingDuration(duration time.Duration) error

Set the metrics logging time duration.

Types

type Metric added in v1.9.0

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

Metric holds a named int64 value. int64 is the only supported metric value type.

func RegisterMetric added in v1.9.0

func RegisterMetric(groupName, metricName string) *Metric

RegisterMetric registers a new metric. The caller should not take the ownership of the returned pointer. If the same metric is registered multiple times, the pointer to the first object is returned.

func (*Metric) Add added in v1.9.0

func (m *Metric) Add(delta int64) int64

Add increase / decrease the metric value.

func (*Metric) Load added in v1.9.0

func (m *Metric) Load() int64

Load returns the current metric value.

func (*Metric) Name added in v1.9.0

func (m *Metric) Name() string

Name returns the name of metric.

func (*Metric) Store added in v1.9.0

func (m *Metric) Store(val int64)

Store saves a new metric value.

type MetricGroup added in v1.9.0

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

MetricGroup holds a list of metric under the same group.

func GetMetricGroupByName added in v1.9.0

func GetMetricGroupByName(groupName string) *MetricGroup

GetMetricGroupByName returns the MetricGroup by name. It returns nil if the MetricGroup is not found.

func (*MetricGroup) DisableLogging added in v1.9.0

func (g *MetricGroup) DisableLogging()

DisableLogging disables logging of this MetricGroup.

func (*MetricGroup) EnableLogging added in v1.9.0

func (g *MetricGroup) EnableLogging()

EnableLogging enables logging of this MetricGroup.

func (*MetricGroup) IsLoggingEnabled added in v1.9.0

func (g *MetricGroup) IsLoggingEnabled() bool

IsLoggingEnabled returns if logging is enabled in this MetricGroup.

func (*MetricGroup) NewLogFields added in v1.9.0

func (g *MetricGroup) NewLogFields() log.Fields

NewLogFields creates log fields from the MetricGroup.

func (*MetricGroup) NewLogMsg added in v1.9.0

func (g *MetricGroup) NewLogMsg() string

NewLogMsg creates a base log message without fields from the MetricGroup.

type MetricGroupList added in v1.9.0

type MetricGroupList []*MetricGroup

MetricGroupList is a list of MetricGroup.

func (MetricGroupList) Append added in v1.9.0

func (l MetricGroupList) Append(group *MetricGroup) MetricGroupList

Append adds a new MetricGroup to the end of list.

func (MetricGroupList) Len added in v1.9.0

func (l MetricGroupList) Len() int

Len implements sort.Interface.

func (MetricGroupList) Less added in v1.9.0

func (l MetricGroupList) Less(i, j int) bool

Less implements sort.Interface.

func (MetricGroupList) Swap added in v1.9.0

func (l MetricGroupList) Swap(i, j int)

Swap implements sort.Interface.

Jump to

Keyboard shortcuts

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