# README
Promgo
Install
$ go get -u github.com/cyrnicolase/promgo
Usage
var (
// APIRequestTotal 接口请求量
APIRequestTotal promgo.Counter
)
func init() {
rdb := redis.NewClient(&redis.Options{
Addr: `:6379`,
})
APIRequestTotal = promgo.NewCounter(rdb, promgo.CounterOptions{
Name: `api_request_total`,
Help: `api request counter`,
Labels: []string{`method`, `endpoint`},
})
promgo.GetDefaultRegistry().MustRegister(APIRequestTotal)
}
func main() {
http.HandleFunc(`/index`, func(rw http.ResponseWriter, r *http.Request) {
ctx, cancel := context.WithTimeout(r.Context(), time.Second)
defer cancel()
APIRequestTotal.Inc(ctx, promgo.ConstLables{
`method`: r.Method,
`endpoint`: r.URL.Path,
})
fmt.Fprint(rw, `hello`)
})
http.HandleFunc(`/metrics`, promgo.Render())
http.ListenAndServe(`:1234`, nil)
}
# Packages
No description provided by the author
# Functions
GetDefaultRegistry ...
NewCounter ...
NewGauge ...
NewHistogram ...
NewMetric ...
NewMetricErr 指标以及可能的错误.
NewRegistry ...
Render ...
# Constants
CollectorPrefix ...
CounterValue 计数器数字.
FieldSeperator 域分隔符.
GaugeValue 面版.
HistogramValue 直方图.
WorkerCount 执行协程数量.
# Variables
DefaultBuckets 默认.
# Structs
CollectorOptions 参数管理.
Desc 指标描述信息.
Metric 指标.
MetricErr 指标以及生成错误.
Registry ...
# Interfaces
Collector ...
CollectorRegister ...
Counter 计数器.
Gauge dashboard.
Histogram 直方图.
# Type aliases
ConstLabels 代表收集指标的标签 name->value 的映射关系.
CounterOptions ...
Descs ...
GaugeOptions ...
HistogramOptions 直方图参数.
Metrics ...
ValueType ...