prom

package
Version: v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

*------------------------------------------------------------**

* @filename prom/prometheus.go
* @author   jinycoo
* @version  1.0.0
* @date     2019-07-25 14:34
* @desc     prom - prometheus monitor
**------------------------------------------------------------*

*------------------------------------------------------------**

* @filename prom/xxx.go
* @author   jinycoo - caojingyin@jinycoo.com
* @version  1.0.0
* @date     2019/12/31 18:01
* @desc     prom - summary
**------------------------------------------------------------*

Index

Constants

This section is empty.

Variables

View Source
var (
	// LibClient for mc redis and db client.
	LibClient = New().WithTimer("go_lib_client", []string{"method"}).WithState("go_lib_client_state", []string{"method", "name"}).WithCounter("go_lib_client_code", []string{"method", "code"})
	// RPCClient rpc client
	RPCClient = New().WithTimer("go_rpc_client", []string{"method"}).WithState("go_rpc_client_state", []string{"method", "name"}).WithCounter("go_rpc_client_code", []string{"method", "code"})
	// HTTPClient http client
	HTTPClient = New().WithTimer("go_http_client", []string{"method"}).WithState("go_http_client_state", []string{"method", "name"}).WithCounter("go_http_client_code", []string{"method", "code"})
	// HTTPServer for http server
	HTTPServer = New().WithTimer("go_http_server", []string{"user", "method"}).WithCounter("go_http_server_code", []string{"user", "method", "code"})
	// RPCServer for rpc server
	RPCServer = New().WithTimer("go_rpc_server", []string{"user", "method"}).WithCounter("go_rpc_server_code", []string{"user", "method", "code"})
	// BusinessErrCount for business err count
	BusinessErrCount = New().WithCounter("go_business_err_count", []string{"name"}).WithState("go_business_err_state", []string{"name"})
	// BusinessInfoCount for business info count
	BusinessInfoCount = New().WithCounter("go_business_info_count", []string{"name"}).WithState("go_business_info_state", []string{"name"})
	// CacheHit for cache hit
	CacheHit = New().WithCounter("go_cache_hit", []string{"name"})
	// CacheMiss for cache miss
	CacheMiss = New().WithCounter("go_cache_miss", []string{"name"})
)

Functions

This section is empty.

Types

type Prom

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

Prom struct info

func New

func New() *Prom

New creates a Prom instance.

func (*Prom) Add

func (p *Prom) Add(name string, v int64, extra ...string)

Add add count v must > 0

func (*Prom) Decr

func (p *Prom) Decr(name string, extra ...string)

Decr decrements one stat counter without sampling

func (*Prom) Incr

func (p *Prom) Incr(name string, extra ...string)

Incr increments one stat counter without sampling

func (*Prom) State

func (p *Prom) State(name string, v int64, extra ...string)

State set state

func (*Prom) Timing

func (p *Prom) Timing(name string, time int64, extra ...string)

Timing log timing information (in milliseconds) without sampling

func (*Prom) WithCounter

func (p *Prom) WithCounter(name string, labels []string) *Prom

WithCounter sets counter.

func (*Prom) WithState

func (p *Prom) WithState(name string, labels []string) *Prom

WithState sets state.

func (*Prom) WithTimer

func (p *Prom) WithTimer(name string, labels []string) *Prom

WithTimer with summary timer

type StatsCollector

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

StatsCollector implements the prometheus.Collector interface.

func NewStatsCollector

func NewStatsCollector(dbName string, sg StatsGetter) *StatsCollector

NewStatsCollector creates a new StatsCollector.

func (StatsCollector) Collect

func (c StatsCollector) Collect(ch chan<- prometheus.Metric)

Collect implements the prometheus.Collector interface.

func (StatsCollector) Describe

func (c StatsCollector) Describe(ch chan<- *prometheus.Desc)

Describe implements the prometheus.Collector interface.

type StatsGetter

type StatsGetter interface {
	Stats() sql.DBStats
}

StatsGetter is an interface that gets sql.DBStats. It's implemented by e.g. *sql.DB or *sqlx.DB.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL