metrics

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2025 License: MIT Imports: 9 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 {
	// 指标的命名空间
	Namespace string
	// HTTP服务器的地址
	HTTPAddr string
	// 指标路径
	MetricsPath string
	// 是否启用
	Enabled bool
	// 收集的指标类型
	EnabledMetrics MetricTypes
}

Config 是Prometheus插件的配置

func DefaultConfig

func DefaultConfig() Config

DefaultConfig 返回默认配置

type MetricTypes

type MetricTypes struct {
	// 请求计数器
	RequestCounter bool
	// 请求延迟
	RequestLatency bool
	// 请求大小
	RequestSize bool
	// 响应大小
	ResponseSize bool
	// 活跃连接数
	ActiveConnections bool
	// 活跃流数
	ActiveStreams bool
}

MetricTypes 表示启用的指标类型

type Metrics

type Metrics struct {
	// 请求计数
	RequestCounter *prometheus.CounterVec
	// 请求延迟
	RequestLatency *prometheus.HistogramVec
	// 请求大小
	RequestSize *prometheus.HistogramVec
	// 响应大小
	ResponseSize *prometheus.HistogramVec
	// 活跃连接数
	ActiveConnections prometheus.Gauge
	// 活跃流数
	ActiveStreams *prometheus.GaugeVec
}

Metrics 包含所有注册的指标

type PrometheusPlugin

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

PrometheusPlugin 是一个用于收集Prometheus指标的插件

func NewPrometheusPlugin

func NewPrometheusPlugin(config Config) *PrometheusPlugin

NewPrometheusPlugin 创建一个新的Prometheus插件

func (*PrometheusPlugin) Close

func (p *PrometheusPlugin) Close() error

Close 实现Plugin接口

func (*PrometheusPlugin) Init

func (p *PrometheusPlugin) Init() error

Init 实现Plugin接口

func (*PrometheusPlugin) Name

func (p *PrometheusPlugin) Name() string

Name 实现Plugin接口

func (*PrometheusPlugin) RegisterWithServer

func (p *PrometheusPlugin) RegisterWithServer(*grpc.Server) error

RegisterWithServer 实现ServerPlugin接口

func (*PrometheusPlugin) StreamClientInterceptor

func (p *PrometheusPlugin) StreamClientInterceptor() grpc.StreamClientInterceptor

StreamClientInterceptor 实现InterceptorPlugin接口

func (*PrometheusPlugin) StreamServerInterceptor

func (p *PrometheusPlugin) StreamServerInterceptor() grpc.StreamServerInterceptor

StreamServerInterceptor 实现InterceptorPlugin接口

func (*PrometheusPlugin) UnaryClientInterceptor

func (p *PrometheusPlugin) UnaryClientInterceptor() grpc.UnaryClientInterceptor

UnaryClientInterceptor 实现InterceptorPlugin接口

func (*PrometheusPlugin) UnaryServerInterceptor

func (p *PrometheusPlugin) UnaryServerInterceptor() grpc.UnaryServerInterceptor

UnaryServerInterceptor 实现InterceptorPlugin接口

Jump to

Keyboard shortcuts

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