collector

package
v2.36.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: MIT Imports: 8 Imported by: 0

README

Perkakas Collector

This library helps you to send go collector and process collector backed by statsd

Component

  • go_collector: go collector including goroutine, gc, etc
  • process_collector: process collector including virtual mem, resident mem, and file descriptor. only available in linux since it reads from /proc

How To use

st, err := statsd.New(telegrafURL)
if err != nil {
	return err
}

// set namespace in each service
st.Namespace = fmt.Sprintf("%s_", "service_namespace")

reg := collector.NewRegistry(time.Second)

// register go collector
reg.Register(collector.NewGoCollector(st))

// register process collector
reg.Register(collector.NewProcessCollector(st))

// run it
go reg.Collect()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoCollector

type GoCollector struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewGoCollector

func NewGoCollector(st *statsd.Client) *GoCollector

func (*GoCollector) Collect

func (g *GoCollector) Collect()

func (*GoCollector) Name

func (g *GoCollector) Name() string

type ICollector

type ICollector interface {
	Collect()
	Name() string
}

type ProcessCollector

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

func NewProcessCollector

func NewProcessCollector(st *statsd.Client) *ProcessCollector

func (*ProcessCollector) Collect

func (p *ProcessCollector) Collect()

func (*ProcessCollector) Name

func (p *ProcessCollector) Name() string

type Registry

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

func NewRegistry

func NewRegistry(interval time.Duration) *Registry

func (*Registry) Collect

func (r *Registry) Collect()

func (*Registry) NumCollectors

func (r *Registry) NumCollectors() int

func (*Registry) Register

func (r *Registry) Register(c ICollector)

func (*Registry) Stop

func (r *Registry) Stop()

Jump to

Keyboard shortcuts

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