Documentation ¶
Index ¶
- Constants
- func Inc(fullname string, lvs ...string)
- func Register(t Type, fullname string, lbls ...string) error
- func Report(fullname string, v float64, lvs ...string)
- func ReportTime(fullname string, lvs ...string) func()
- type Config
- type Counter
- type CurryMetric
- type GenericMetric
- type MetricFactory
- type Observer
- type Type
Constants ¶
View Source
const ( TypeGauge = "gauge" TypeSummary = "summary" TypeCounter = "counter" )
The concrete monitor metric type
Variables ¶
This section is empty.
Functions ¶
func ReportTime ¶
ReportTime is a util function to report a `used time', e.g: defer ReportTime(xxx)()
Types ¶
type CurryMetric ¶
type CurryMetric struct {
Func func(lbls ...string) GenericMetric
}
CurryMetric wraps generic metrics. Usage:
counterVec := prometheus.NewCounterVec(...) factory.Register("count_metric_name", CurryMetric{func (lbls ...string) GenericMetric { return counterVec.WithLabelValues(lbls...) }})
func (CurryMetric) Add ¶
func (c CurryMetric) Add(v float64, lbls ...string)
Add increments the metric by `v`.
func (CurryMetric) Elapsed ¶
func (c CurryMetric) Elapsed(start time.Time, lbls ...string)
Elapsed report an elapsed time in micro-seconds since `start`
func (CurryMetric) Observe ¶
func (c CurryMetric) Observe(f float64, lbls ...string)
Observe set the value.
func (CurryMetric) Set ¶
func (c CurryMetric) Set(v float64, lbls ...string)
Set set the metric value as `v`.
type MetricFactory ¶
type MetricFactory struct {
// contains filtered or unexported fields
}
MetricFactory provides api to get prometheus metrics by string name.
func NewMetricFactory ¶
func NewMetricFactory() *MetricFactory
NewMetricFactory constructs a new metric factory.
func (*MetricFactory) Get ¶
func (f *MetricFactory) Get(name string) CurryMetric
Get get a metric, return a dummy metric if not existed
func (*MetricFactory) Must ¶
func (f *MetricFactory) Must(name string) CurryMetric
Must get a metric, panic if not existed.
func (*MetricFactory) Register ¶
func (f *MetricFactory) Register(name string, m CurryMetric)
Register registers a metric in this factory.
Click to show internal directories.
Click to hide internal directories.