Documentation ¶
Index ¶
- type MetricsPlugin
- func (m *MetricsPlugin) AddCustomGauge(name, help string, constLabels map[string]string) prometheus.Gauge
- func (m *MetricsPlugin) AddCustomSummaryVec(name, help string, labels []string, objectives map[float64]float64, ...) *prometheus.SummaryVec
- func (m *MetricsPlugin) Apply(router *gin.Engine)
- func (m *MetricsPlugin) RegisterMetrics()
- func (m *MetricsPlugin) TrackActiveRequestsMiddleware() gin.HandlerFunc
- func (m *MetricsPlugin) TrackResponseTimeMiddleware() gin.HandlerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MetricsPlugin ¶
type MetricsPlugin struct { Namespace string Subsystem string InstanceID string // contains filtered or unexported fields }
func NewMetricsPlugin ¶
func NewMetricsPlugin(namespace, subsystem, instanceID string) *MetricsPlugin
func (*MetricsPlugin) AddCustomGauge ¶
func (m *MetricsPlugin) AddCustomGauge(name, help string, constLabels map[string]string) prometheus.Gauge
AddCustomGauge 添加一个自定义的 Gauge 类型的指标
func (*MetricsPlugin) AddCustomSummaryVec ¶
func (m *MetricsPlugin) AddCustomSummaryVec(name, help string, labels []string, objectives map[float64]float64, constLabels map[string]string) *prometheus.SummaryVec
AddCustomSummaryVec 添加一个自定义的 SummaryVec 类型的指标
func (*MetricsPlugin) Apply ¶
func (m *MetricsPlugin) Apply(router *gin.Engine)
Apply 将所有的 Prometheus 中间件应用到 Gin 路由
func (*MetricsPlugin) RegisterMetrics ¶
func (m *MetricsPlugin) RegisterMetrics()
RegisterMetrics 注册所有 Prometheus 指标 包括响应时间SummaryVec和活跃请求数Gauge
func (*MetricsPlugin) TrackActiveRequestsMiddleware ¶
func (m *MetricsPlugin) TrackActiveRequestsMiddleware() gin.HandlerFunc
TrackActiveRequestsMiddleware 返回一个 Gin 中间件,用于跟踪活跃 HTTP 请求数
func (*MetricsPlugin) TrackResponseTimeMiddleware ¶
func (m *MetricsPlugin) TrackResponseTimeMiddleware() gin.HandlerFunc
TrackResponseTimeMiddleware 返回一个 Gin 中间件,用于跟踪 HTTP 请求的响应时间
Click to show internal directories.
Click to hide internal directories.