exporter

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2019 License: Apache-2.0 Imports: 15 Imported by: 70

Documentation

Index

Constants

View Source
const (
	RegisterPeriod = time.Duration(1) * time.Minute
	RegisterPath   = "/v1/agent/service/register"
)
View Source
const (
	PromHandlerPattern    = "/metrics"     // prometheus handler
	AppName               = "cfs"          //app name
	ConfigKeyExporterPort = "exporterPort" //exporter port
	ConfigKeyConsulAddr   = "consulAddr"   //consul addr
	ChSize                = 1024 * 10      //collect chan size
)

Variables

View Source
var (
	AlarmPool = &sync.Pool{New: func() interface{} {
		return new(Alarm)
	}}
	//AlarmGroup  sync.Map
	AlarmCh chan *Alarm
)
View Source
var (
	CounterGroup sync.Map
	CounterPool  = &sync.Pool{New: func() interface{} {
		return new(Counter)
	}}
	CounterCh chan *Counter
)
View Source
var (
	GaugePool = &sync.Pool{New: func() interface{} {
		return new(Gauge)
	}}

	GaugeGroup sync.Map
	GaugeCh    chan *Gauge
)
View Source
var (
	TPPool = &sync.Pool{New: func() interface{} {
		return new(TimePoint)
	}}
	TPCh chan *TimePoint
)

Functions

func GetConsulId

func GetConsulId(app string, role string, host string, port int64) string

get consul id

func GetLocalIpAddr

func GetLocalIpAddr() (ipaddr string, err error)

GetLocalIpAddr returns the local IP address.

func Init

func Init(cluster string, role string, cfg *config.Config)

Init initializes the exporter.

func RegisterConsul

func RegisterConsul(addr, app, role, cluster string, port int64)

func SendRegisterReq

func SendRegisterReq(addr string, app string, role string, cluster string, port int64)

SendRegisterReq sends the register request.

Types

type Alarm

type Alarm struct {
	Counter
}

func NewAlarm

func NewAlarm(name string) (a *Alarm)

type ConsulRegisterInfo

type ConsulRegisterInfo struct {
	Name    string
	ID      string
	Address string
	Port    int64
	Tags    []string
}

*

  • consul register info for prometheus
  • optional for user when set prometheus exporter

type Counter

type Counter struct {
	Gauge
}

func NewCounter

func NewCounter(name string) (c *Counter)

func (*Counter) Add

func (c *Counter) Add(val int64)

func (*Counter) AddWithLabels

func (c *Counter) AddWithLabels(val int64, labels map[string]string)

func (*Counter) Metric

func (c *Counter) Metric() prometheus.Counter

type Gauge

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

func NewGauge

func NewGauge(name string) (g *Gauge)

func (*Gauge) Key

func (c *Gauge) Key() (key string)

func (*Gauge) Metric

func (c *Gauge) Metric() prometheus.Gauge

func (*Gauge) Set

func (g *Gauge) Set(val int64)

func (*Gauge) SetWithLabels

func (g *Gauge) SetWithLabels(val int64, labels map[string]string)

type TimePoint

type TimePoint struct {
	Gauge
	// contains filtered or unexported fields
}

func NewTP

func NewTP(name string) (tp *TimePoint)

func (*TimePoint) Set

func (tp *TimePoint) Set()

type TimePointCount

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

func NewTPCnt

func NewTPCnt(name string) (tpc *TimePointCount)

func (*TimePointCount) Set

func (tpc *TimePointCount) Set()

Jump to

Keyboard shortcuts

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