stats

package
v0.0.0-...-b8a1a0e Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DATABASE = "telegraf"
)
View Source
const (
	TICK_CYCLE = 10 * time.Second
)
View Source
const (
	// UDPPayloadSize is a reasonable default payload size for UDP packets that
	// could be travelling over the internet.
	UDPPayloadSize = 1024
)

Variables

View Source
var (
	MinInterval = TICK_CYCLE
)

Functions

func RegisterCountable

func RegisterCountable(module string, countable Countable, opts ...Option) error

func RegisterCountableWithModulePrefix

func RegisterCountableWithModulePrefix(modulePrefix, module string, countable Countable, opts ...Option) error

func RegisterGcMonitor

func RegisterGcMonitor()

func RegisterPreHook

func RegisterPreHook(hook func())

func ReleaseDFStats

func ReleaseDFStats(s *DFStats)

func SetDFRemote

func SetDFRemote(addr string)

addr格式: "192.168.1.1:20033"

func SetHostname

func SetHostname(name string)

func SetMinInterval

func SetMinInterval(interval time.Duration)

限定stats的最少interval,也就是不论注册Countable时 指定的Interval是多少,只要比此值低就优先使用此值

func SetProcessName

func SetProcessName(name string)

func SetProcessNameJoiner

func SetProcessNameJoiner(joiner string)

func SetRemoteType

func SetRemoteType(t RemoteType)

指定远程服务器类型,默认influxdb

func SetRemotes

func SetRemotes(addrs ...string)

指定influxdb远程服务器 只会有其中一个远程服务器会收到统计数据 addr格式: "192.168.1.1:20033"

Types

type Countable

type Countable interface {
	// needs to be thread-safe, clear is required after read
	// accept struct or []StatItem
	GetCounter() interface{}

	// once closed, countable will be removed from stats
	Closed() bool
}

type DFStats

type DFStats struct {
	Time      uint32
	TableName string
	Tags      []Tag
	Fields    []Field
}

func AcquireDFStats

func AcquireDFStats() *DFStats

func Decode

func Decode(decoder *codec.SimpleDecoder) (*DFStats, error)

func (*DFStats) Encode

func (s *DFStats) Encode(encoder *codec.SimpleEncoder)

func (*DFStats) GenCKTable

func (s *DFStats) GenCKTable(ttl int) *ckdb.Table

func (*DFStats) Key

func (s *DFStats) Key() uint64

用来区分该统计属于哪个表,取表名,tag,field 的hash,返回uint64

func (*DFStats) Release

func (s *DFStats) Release()

func (*DFStats) WriteBlock

func (s *DFStats) WriteBlock(block *ckdb.Block) error

type Field

type Field struct {
	Key   string
	Type  ValueType
	Value int64
}

type GcMonitor

type GcMonitor struct {
	utils.Closable
	// contains filtered or unexported fields
}

func (*GcMonitor) GetCounter

func (t *GcMonitor) GetCounter() interface{}

type Option

type Option = interface{}

type OptionInterval

type OptionInterval time.Duration // must be time.Second, time.Minute or time.Hour

type OptionStatTags

type OptionStatTags = map[string]string

type RemoteType

type RemoteType = uint8
const (
	REMOTE_TYPE_INFLUXDB RemoteType = 1 << iota
	REMOTE_TYPE_STATSD
	REMOTE_TYPE_DFSTATSD
)

type StatItem

type StatItem struct {
	Name  string
	Value interface{}
}

type StatSource

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

func (*StatSource) Equal

func (s *StatSource) Equal(other *StatSource) bool

func (*StatSource) String

func (s *StatSource) String() string

type Tag

type Tag struct {
	Key   string
	Value string
}

type UDPClient

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

func NewUDPClient

func NewUDPClient(conf UDPConfig) (*UDPClient, error)

NewUDPClient returns a client interface for writing to an InfluxDB UDP service from the given config.

func (*UDPClient) Close

func (uc *UDPClient) Close() error

Close releases the UDPClient's resources.

func (*UDPClient) Write

func (uc *UDPClient) Write(bs []byte) error

type UDPConfig

type UDPConfig struct {
	// Addr should be of the form "host:port"
	// or "[ipv6-host%zone]:port".
	Addr string

	// PayloadSize is the maximum size of a UDP client message, optional
	// Tune this based on your network. Defaults to UDPPayloadSize.
	PayloadSize int
}

UDPConfig is the config data needed to create a UDP Client.

type ValueType

type ValueType uint8
const (
	TypeInt64 ValueType = iota
	TypeFloat64
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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