Documentation ¶
Index ¶
Constants ¶
View Source
const ( MaxLogWaitDuration = 800 * time.Millisecond MaxZeroDuration = 3 MetricsNumber = 5 MaxAddDuration = 800 * time.Millisecond )
View Source
const ( // metric name // MetricForClientRqTimeout time consumed per interface call MetricForClientRqTimeout string = "client_rq_timeout" // MetricForClientRqIntervalCount total number of client request in current interval MetricForClientRqIntervalCount string = "client_rq_interval_count" // MetricForClientRqTimeoutMin max latency of client requests MetricForClientRqTimeoutMin string = "client_rq_timeout_min" // MetricForClientRqTimeoutAvg min latency of client requests MetricForClientRqTimeoutAvg string = "client_rq_timeout_avg" // MetricForClientRqTimeoutMax average latency of client requests MetricForClientRqTimeoutMax string = "client_rq_timeout_max" // metric type TypeForGaugeVec string = "gauge_vec" )
Variables ¶
View Source
var ( // metricDescList Metrics Description Defines the list MetricDescList = []metricDesc{ { Name: MetricForClientRqTimeout, Help: "time consumed per interface call", MetricType: TypeForGaugeVec, LabelNames: []string{ metrics.LabelApi, metrics.LabelProtocol, metrics.LabelErrCode, }, }, { Name: MetricForClientRqIntervalCount, Help: "total number of client request in current interval", MetricType: TypeForGaugeVec, LabelNames: []string{ metrics.LabelApi, metrics.LabelProtocol, metrics.LabelErrCode, }, }, { Name: MetricForClientRqTimeoutMax, Help: "max latency of client requests", MetricType: TypeForGaugeVec, LabelNames: []string{ metrics.LabelApi, metrics.LabelProtocol, metrics.LabelErrCode, }, }, { Name: MetricForClientRqTimeoutMin, Help: "min latency of client requests", MetricType: TypeForGaugeVec, LabelNames: []string{ metrics.LabelApi, metrics.LabelProtocol, metrics.LabelErrCode, }, }, { Name: MetricForClientRqTimeoutAvg, Help: "average latency of client requests", MetricType: TypeForGaugeVec, LabelNames: []string{ metrics.LabelApi, metrics.LabelProtocol, metrics.LabelErrCode, }, }, } )
Functions ¶
func BuildMetricLabels ¶
func BuildMetricLabels(item *APICallStatisItem) map[string]string
BuildMetricLabels build metric label from APICall or APICallStatisItem
Types ¶
type APICall ¶
type APICall struct { Count int Api string Code int Duration int64 Protocol string TrafficDirection string Component metrics.CallMetricType }
APICall 接口调用
type APICallStatisItem ¶
type APICallStatisItem struct { API string TrafficDirection string Code int Count int64 AccTime int64 MinTime int64 MaxTime int64 Protocol string ZeroDuration int64 // 没有请求持续的时间,持续时间长超过阈值从 prometheus 中移除掉 }
APICallStatisItem 接口调用统计条目
type BaseWorker ¶
type BaseWorker struct {
// contains filtered or unexported fields
}
func NewBaseWorker ¶
func NewBaseWorker(ctx context.Context, handler MetricsHandler) (*BaseWorker, error)
func (*BaseWorker) ReportCallMetrics ¶
func (s *BaseWorker) ReportCallMetrics(metric metrics.CallMetric)
ReportCallMetrics report call metrics info
type CacheCallStatis ¶
type CacheCallStatis struct {
// contains filtered or unexported fields
}
CacheCallStatis 接口调用统计
func NewCacheCallStatis ¶
func NewCacheCallStatis(ctx context.Context) (*CacheCallStatis, error)
type CacheCallStatisItem ¶
type CacheCallStatisItem struct {
// contains filtered or unexported fields
}
CacheCallStatisItem 接口调用统计条目
type CacheStatics ¶
type CacheStatics struct { CacheCallStatis *CacheCallStatis // contains filtered or unexported fields }
ComponentCacheStatics statics components
func NewCacheStatics ¶
func NewCacheStatics(statis *CacheCallStatis) *CacheStatics
func (*CacheStatics) Add ¶
func (c *CacheStatics) Add(ac metrics.CallMetric)
type ComponentStatics ¶
type ComponentStatics struct {
// contains filtered or unexported fields
}
ComponentStatics statics components
func NewComponentStatics ¶
func NewComponentStatics(ctx context.Context, t metrics.CallMetricType, handler MetricsHandler) *ComponentStatics
type MetricData ¶
MetricData metric 结构体
type MetricsHandler ¶
type MetricsHandler func(mt metrics.CallMetricType, start time.Time, staticsSlice []*APICallStatisItem)
Click to show internal directories.
Click to hide internal directories.