metric

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorLog added in v0.1.9

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

ErrorLog 结构体包装了 logr.Logger,用于处理 Prometheus 指标错误日志。 The ErrorLog struct wraps logr.Logger to handle Prometheus metrics error logging.

func NewErrorLog added in v0.1.9

func NewErrorLog(l *logr.Logger) *ErrorLog

NewErrorLog 函数返回一个新的 ErrorLog 实例。 The NewErrorLog function returns a new ErrorLog instance.

func (*ErrorLog) Println added in v0.1.9

func (e *ErrorLog) Println(v ...interface{})

Println 方法实现了 Prometheus 客户端所需的错误日志接口。 The Println method implements the error logging interface required by Prometheus client.

type ServerMetrics

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

ServerMetrics 结构体包含了请求计数器、请求延迟直方图、请求延迟仪表盘和 Prometheus 注册表。 The ServerMetrics struct contains a request counter, request latency histogram, request latency gauge, and Prometheus registry.

func NewServerMetrics

func NewServerMetrics(registry *prometheus.Registry) *ServerMetrics

NewServerMetrics 函数返回一个新的 ServerMetrics 实例�� The NewServerMetrics function returns a new ServerMetrics instance.

func (*ServerMetrics) HandlerFunc

func (m *ServerMetrics) HandlerFunc(logger *logr.Logger) gin.HandlerFunc

HandlerFunc 返回一个 Gin 中间件处理函数。 HandlerFunc returns a Gin middleware handler function.

func (*ServerMetrics) IncRequestCount

func (m *ServerMetrics) IncRequestCount(method, path, status string)

IncRequestCount 方法增加请求计数。 The IncRequestCount method increments the request count.

func (*ServerMetrics) ObserveRequestLatency

func (m *ServerMetrics) ObserveRequestLatency(method, path, status string, latency float64)

ObserveRequestLatency 方法观察请求延迟。 The ObserveRequestLatency method observes the request latency.

func (*ServerMetrics) Register

func (m *ServerMetrics) Register()

Register 方法将度量标准注册到 Prometheus 注册表。 The Register method registers the metrics to the Prometheus registry.

func (*ServerMetrics) Reset

func (m *ServerMetrics) Reset()

Reset 方法重置所有度量标准。 The Reset method resets all metrics.

func (*ServerMetrics) ResetRequestCount

func (m *ServerMetrics) ResetRequestCount(method, path, status string)

ResetRequestCount 方法重置请求计数器。 The ResetRequestCount method resets the request counter.

func (*ServerMetrics) ResetRequestLatencies

func (m *ServerMetrics) ResetRequestLatencies(method, path, status string)

ResetRequestLatencies 方法重置请求延迟直方图。 The ResetRequestLatencies method resets the request latency histogram.

func (*ServerMetrics) ResetRequestLatency

func (m *ServerMetrics) ResetRequestLatency(method, path, status string)

ResetRequestLatency 方法重置请求延迟。 The ResetRequestLatency method resets the request latency.

func (*ServerMetrics) SetRequestLatency

func (m *ServerMetrics) SetRequestLatency(method, path, status string, latency float64)

SetRequestLatency 方法设置请求延迟。 The SetRequestLatency method sets the request latency.

func (*ServerMetrics) Unregister

func (m *ServerMetrics) Unregister()

Unregister 方法将度量标准从 Prometheus 注册表中注销。 The Unregister method unregisters the metrics from the Prometheus registry.

Jump to

Keyboard shortcuts

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