metrics

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 License: Apache-2.0 Imports: 18 Imported by: 68

Documentation

Overview

Package metrics is the package that contains those implementations to emit metrics to reflect the running states of current process.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DummyMetrics

type DummyMetrics struct{}

func (DummyMetrics) Run

func (d DummyMetrics) Run(_ context.Context)

func (DummyMetrics) StoreFloat64

func (d DummyMetrics) StoreFloat64(_ string, _ float64, _ MetricTypeName, _ ...MetricTag) error

func (DummyMetrics) StoreInt64

func (d DummyMetrics) StoreInt64(_ string, _ int64, _ MetricTypeName, _ ...MetricTag) error

func (DummyMetrics) WithTags

func (d DummyMetrics) WithTags(unit string, commonTags ...MetricTag) MetricEmitter

type MetricEmitter

type MetricEmitter interface {
	// StoreInt64 receives the given int64 metrics item and sends it the backend store.
	StoreInt64(key string, val int64, emitType MetricTypeName, tags ...MetricTag) error
	// StoreFloat64 receives the given float64 metrics item and sends it the backend store.
	StoreFloat64(key string, val float64, emitType MetricTypeName, tags ...MetricTag) error
	// WithTags add unit tag and common tags to emitter.
	WithTags(unit string, commonTags ...MetricTag) MetricEmitter
	// Run is ensure the starting logic works, since emitter like
	// prometheus need to be started to trigger gc logic
	Run(ctx context.Context)
}

MetricEmitter interface defines the action of emitting metrics, support to use different kinds of metrics emitter if needed

func NewOpenTelemetryPrometheusMetricsEmitter

func NewOpenTelemetryPrometheusMetricsEmitter(metricsConf *generic.MetricsConfiguration, pathName PrometheusMetricPathName,
	mux *http.ServeMux) (MetricEmitter, error)

NewOpenTelemetryPrometheusMetricsEmitter implement a MetricEmitter use open-telemetry sdk.

type MetricTag

type MetricTag struct {
	Key, Val string
}

func ConvertMapToTags

func ConvertMapToTags(tags map[string]string) []MetricTag

ConvertMapToTags only pass map to metrics related function

type MetricTagWrapper

type MetricTagWrapper struct {
	MetricEmitter
	// contains filtered or unexported fields
}

MetricTagWrapper is a wrapped implementation for MetricEmitter it contains a standard MetricEmitter implementation along with pre-defined common metrics tags

func (*MetricTagWrapper) Run

func (t *MetricTagWrapper) Run(ctx context.Context)

func (*MetricTagWrapper) StoreFloat64

func (t *MetricTagWrapper) StoreFloat64(key string, val float64, emitType MetricTypeName, tags ...MetricTag) error

func (*MetricTagWrapper) StoreInt64

func (t *MetricTagWrapper) StoreInt64(key string, val int64, emitType MetricTypeName, tags ...MetricTag) error

func (*MetricTagWrapper) WithTags

func (t *MetricTagWrapper) WithTags(unit string, commonTags ...MetricTag) MetricEmitter

type MetricTypeName

type MetricTypeName string
const (
	// The MetricTypeNameRaw is stateless, the MetricTypeNameCount and MetricTypeNameUpDownCount
	// are stateful, so when we need store metrics with high dimension tags (such as pod name or uuid),
	// we must use MetricTypeNameRaw to avoid oom.
	// MetricTypeNameRaw emit raw metrics which report the last value
	MetricTypeNameRaw MetricTypeName = "raw"
	// MetricTypeNameCount emit counter metrics which is monotonic
	MetricTypeNameCount MetricTypeName = "count"
	// MetricTypeNameUpDownCount emit up down count metrics which isn't monotonic
	MetricTypeNameUpDownCount MetricTypeName = "up_down_count"
)

type PrometheusMetricPathName

type PrometheusMetricPathName string
const (
	PrometheusMetricPathNameDefault      PrometheusMetricPathName = "/metrics"
	PrometheusMetricPathNameCustomMetric PrometheusMetricPathName = "/custom_metric"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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