metrics

package
v0.0.0-...-01b7989 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

metrics/aggregator.go

metrics/collector.go

metrics/types.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregateRule

type AggregateRule struct {
	Name      string
	Type      MetricType
	Operation AggregateOperation
	Window    time.Duration
	Quantiles []float64
}

AggregateRule 聚合规则

type CollectorOptions

type CollectorOptions struct {
	// 缓冲区大小
	BufferSize int
	// 工作池大小
	WorkerSize int
	// 采样率
	SampleRate float64
	// 刷新间隔
	FlushInterval time.Duration
	// 存储选项
	StorageOptions StorageOptions
	// 聚合选项
	AggregateOptions AggregateOptions
	// 报告选项
	ReportOptions ReportOptions
}

CollectorOptions 收集器配置

type Counter

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

Counter 计数器实现

func (*Counter) Add

func (c *Counter) Add(delta float64)

func (*Counter) Get

func (c *Counter) Get() float64

func (*Counter) Reset

func (c *Counter) Reset()

func (*Counter) Set

func (c *Counter) Set(v float64)

type Gauge

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

Gauge 仪表实现

func (*Gauge) Add

func (g *Gauge) Add(delta float64)

type Histogram

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

Histogram 直方图实现

func NewHistogram

func NewHistogram(opts HistogramOpts) *Histogram

type HistogramOpts

type HistogramOpts struct {
	Buckets   []float64
	Quantiles []float64
	BufSize   int
}

HistogramOpts 直方图配置

type MetricAggregator

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

MetricAggregator 指标聚合器

func (*MetricAggregator) Aggregate

func (ma *MetricAggregator) Aggregate(metric Metric) (*AggregateResult, error)

type MetricBucket

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

MetricBucket 指标桶

type MetricCollector

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

MetricCollector 指标收集器

func NewMetricCollector

func NewMetricCollector(opts CollectorOptions) (*MetricCollector, error)

NewMetricCollector 创建指标收集器

func (*MetricCollector) Collect

func (mc *MetricCollector) Collect(name string, value float64, labels map[string]string) error

Collect 收集指标值

func (*MetricCollector) RegisterMetric

func (mc *MetricCollector) RegisterMetric(name string, typ MetricType, labels map[string]string) (Metric, error)

RegisterMetric 注册指标

type MetricType

type MetricType string

MetricType 指标类型

const (
	CounterMetric   MetricType = "counter"   // 计数器类型
	GaugeMetric     MetricType = "gauge"     // 仪表类型
	HistogramMetric MetricType = "histogram" // 直方图类型
	SummaryMetric   MetricType = "summary"   // 摘要类型
)

type MetricValue

type MetricValue interface {
	Add(float64)
	Set(float64)
	Get() float64
	Reset()
}

MetricValue 指标值接口

type TimeWindow

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

TimeWindow 时间窗口

Jump to

Keyboard shortcuts

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