smetric

package
v1.4.13 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2021 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
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()
)
View Source
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

func SafePromethuesValue(v string) string

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 Label

type Label struct {
	Name  string
	Value string
}

type Metrics

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

func (*Metrics) AddHistoramSampleCreateIfAbsent

func (p *Metrics) AddHistoramSampleCreateIfAbsent(namekeys []string, val float64, labels []Label, buckets []float64)

func (*Metrics) AddSummarySampleCreateIfAbsent

func (p *Metrics) AddSummarySampleCreateIfAbsent(namekeys []string, val float64, labels []Label, quantile map[float64]float64)

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 (p *Metrics) CreateHistogram(namekeys []string, labels []Label, buckets []float64) prometheus.Histogram

func (*Metrics) CreateSummary

func (p *Metrics) CreateSummary(namekeys []string, labels []Label, quantile map[float64]float64) prometheus.Summary

func (*Metrics) Describe

func (p *Metrics) Describe(c chan<- *prometheus.Desc)

no use only for register

func (*Metrics) Exportor

func (p *Metrics) Exportor() http.Handler

func (*Metrics) IncrCounterCreateIfAbsent

func (p *Metrics) IncrCounterCreateIfAbsent(namekeys []string, val float64, labels []Label)

func (*Metrics) SetGaugeCreateIfAbsent

func (p *Metrics) SetGaugeCreateIfAbsent(namekeys []string, val float64, labels []Label)

type MetricsOpts

type MetricsOpts struct {
	DefBuckets  []float64
	DefQuantile map[float64]float64
}

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

Jump to

Keyboard shortcuts

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