Documentation ¶
Index ¶
- Constants
- Variables
- func CollectServ(instance, servkey string, servid int, processor string, duration time.Duration, ...)
- func NewPromErrorLog() *promErrorLog
- func SafePromethuesValue(v string) string
- type Collector
- type CollectorOpts
- type CollectorType
- type Collectors
- type CollectorsOpts
- type Label
- type Metrics
- func (p *Metrics) AddHistoramSampleCreateIfAbsent(namekeys []string, val float64, labels []Label, buckets []float64)
- func (p *Metrics) AddSummarySampleCreateIfAbsent(namekeys []string, val float64, labels []Label, quantile map[float64]float64)
- func (p *Metrics) Collect(c chan<- prometheus.Metric)
- func (p *Metrics) CreateCounter(namekeys []string, labels []Label) prometheus.Counter
- func (p *Metrics) CreateGauge(namekeys []string, labels []Label) prometheus.Gauge
- func (p *Metrics) CreateHistogram(namekeys []string, labels []Label, buckets []float64) prometheus.Histogram
- func (p *Metrics) CreateSummary(namekeys []string, labels []Label, quantile map[float64]float64) prometheus.Summary
- func (p *Metrics) Describe(c chan<- *prometheus.Desc)
- func (p *Metrics) Exportor() http.Handler
- func (p *Metrics) IncrCounterCreateIfAbsent(namekeys []string, val float64, labels []Label)
- func (p *Metrics) SetGaugeCreateIfAbsent(namekeys []string, val float64, labels []Label)
- type MetricsOpts
- type Metricsprocessor
Constants ¶
const ( Name_space_palfish = "palfish" Name_server_req_total = "server_request_total" Name_server_duration_second = "server_duration_second" Label_instance = "instance" Label_servname = "servname" Label_servid = "servid" Label_api = "api" Label_type = "type" Label_source = "source" Label_status = "status" Status_succ = 1 Status_fail = 0 )
Variables ¶
var ( DefaultMetricsOpts = &MetricsOpts{ DefBuckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10}, DefQuantile: map[float64]float64{.25: .01, .5: .01, .75: .01, .9: .01, .95: .001, .99: .001}, } DefaultMetrics = newMetrics() )
var ( DefaultCollectorsOpts = CollectorsOpts{ Port: 0, Location: "/metrics", DefBuckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10}, DefQuantile: map[float64]float64{.25: .01, .5: .01, .75: .01, .9: .01, .95: .001, .99: .001}, } )
Functions ¶
func CollectServ ¶
func CollectServ(instance, servkey string, servid int, processor string, duration time.Duration, source int, funcName string, err interface{})
服务相关数据收集,主要包括:成功率、响应时间 instance:当前服务实例 servkey:服务标识如base/sla;processor:进程类型 proc_thrift/proc_http duration耗时;source请求源标识,目前都是0;servid:服务id标识;funcName:监控的api标识 err 是否处理有报错
func NewPromErrorLog ¶
func NewPromErrorLog() *promErrorLog
func SafePromethuesValue ¶
Types ¶
type Collector ¶
type Collector interface { Collect(chan<- prometheus.Metric) Sample(v float64) }
type CollectorOpts ¶
type CollectorOpts struct { Type CollectorType Keys []string Labels []Label Buckets []float64 Quantile map[float64]float64 }
CollectorsOpts is used to configure the Collectors
type CollectorType ¶
type CollectorType int32
const ( Counter CollectorType Gauge Histogram Summary Untyped )
Possible values for the ValueType enum.
type Collectors ¶
type Collectors struct {
// contains filtered or unexported fields
}
func NewCollectors ¶
func NewCollectors(opts *CollectorsOpts) (*Collectors, error)
NewCollectors creates a new Collectors using the default options.
func NewCollectorsFrom ¶
func NewCollectorsFrom(opts CollectorsOpts) (*Collectors, error)
NewCollectorsFrom creates a new Collectors using the passed options.
func (*Collectors) Collect ¶
func (p *Collectors) Collect(c chan<- prometheus.Metric)
Collect meets the collection interface and allows us to enforce our expiration logic to clean up ephemeral metrics if their value haven't been set for a duration exceeding our allowed expiration time.
func (*Collectors) CreateCollector ¶
func (p *Collectors) CreateCollector(opts *CollectorOpts) (Collector, error)
func (*Collectors) Describe ¶
func (p *Collectors) Describe(c chan<- *prometheus.Desc)
no use only for register
type CollectorsOpts ¶
type CollectorsOpts struct { Port int Location string DefBuckets []float64 DefQuantile map[float64]float64 }
CollectorsOpts is used to configure the Collectors
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
func (*Metrics) AddHistoramSampleCreateIfAbsent ¶
func (*Metrics) AddSummarySampleCreateIfAbsent ¶
func (*Metrics) Collect ¶
func (p *Metrics) Collect(c chan<- prometheus.Metric)
Collect meets the collection interface and allows us to enforce our expiration logic to clean up ephemeral metrics if their value haven't been set for a duration exceeding our allowed expiration time.
func (*Metrics) CreateCounter ¶
func (p *Metrics) CreateCounter(namekeys []string, labels []Label) prometheus.Counter
func (*Metrics) CreateGauge ¶
func (p *Metrics) CreateGauge(namekeys []string, labels []Label) prometheus.Gauge
func (*Metrics) CreateHistogram ¶
func (*Metrics) CreateSummary ¶
func (*Metrics) Describe ¶
func (p *Metrics) Describe(c chan<- *prometheus.Desc)
no use only for register
func (*Metrics) IncrCounterCreateIfAbsent ¶
type MetricsOpts ¶
MetricsOpts is used to configure the Metrics
type Metricsprocessor ¶
type Metricsprocessor struct {
*Metrics
}
func NewMetricsprocessor ¶
func NewMetricsprocessor() *Metricsprocessor
func (*Metricsprocessor) Driver ¶
func (p *Metricsprocessor) Driver() (string, interface{})
func (*Metricsprocessor) Init ¶
func (p *Metricsprocessor) Init() error