statsd

package
v4.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// metrics支持的聚合类型
	CommonAggregatorsConst = map[string]bool{
		"c": true, "ce": true, "rpc": true, "r": true, "rt": true,
		"p1": true, "p5": true, "p25": true, "p50": true, "p75": true,
		"p90": true, "p95": true, "p99": true, "rpce": true,
		"max": true, "min": true, "sum": true, "avg": true, "cnt": true,
		"g": true,
	}
	HistogramAggregatorsConst = map[string]bool{
		"p1": true, "p5": true, "p25": true, "p50": true, "p75": true,
		"p90": true, "p95": true, "p99": true,
		"max": true, "min": true, "sum": true, "avg": true, "cnt": true,
	}
	Const_CommonAggregator_Rpc  = "rpc"
	Const_CommonAggregator_RpcE = "rpce"

	// rpc状态码
	RpcOkCodesConst = map[string]bool{"ok": true, "0": true,
		"200": true, "201": true, "203": true}

	// metrics支持的最大tag数
	MaxTagsCntConst = 12

	// ns前缀后缀
	NsPrefixConst = ""
	NsSuffixConst = ""

	// 需要聚合的metric
	MetricToBeSummarized_RpcdisfConst     = "rpcdisf"
	MetricToBeSummarized_RpcdfeConst      = "rpcdfe"
	MetricToBeSummarized_DirpcCallConst   = "rpc_dirpc_call"
	MetricToBeSummarized_DirpcCalledConst = "rpc_dirpc_called"

	// summarize等待collect结束的超时时间
	SummarizeWaitCollectTimeoutMsConst = 2000

	// traceid对应的tagk
	TagTraceId = "traceid"

	// LRU 缓存的大小
	MaxLRUCacheSize = 10000

	// 并包模式下的分隔符
	MergeDelimiter = "&"
	// $value,$statusCode的分隔符, 向前兼容, 使用 ","
	CodeDelimiter = ","
)
View Source
var (
	BadRpcMetricError           = fmt.Errorf("bad rpc metric")
	BadSummarizeAggregatorError = fmt.Errorf("bad summarize aggregator")
	BadDeserializeError         = fmt.Errorf("bad deserialize")
	BadAggregatorNameError      = fmt.Errorf("bad aggregator name")
)

Functions

func Exit

func Exit()

func GetTimestamp

func GetTimestamp() int64

func IsExited

func IsExited() bool

func Start

func Start()

func TranslateToN9EPoint

func TranslateToN9EPoint(point *Point) *dataobj.MetricValue

Types

type ArgCacheUnit

type ArgCacheUnit struct {
	Aggrs   []string
	Tags    map[string]string
	ArgLine string
	Error   error
}

func NewArgCacheUnit

func NewArgCacheUnit(argline string, aggrs []string,
	tags map[string]string) *ArgCacheUnit

func NewArgCacheUnitWithError

func NewArgCacheUnitWithError(err error) *ArgCacheUnit

type Clock

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

type Func

type Func struct{}

func (Func) FormatArgLines

func (f Func) FormatArgLines(argLines string, metricLines string) (string, []string, error)

tags+aggr lines

func (Func) FormatMetricLine

func (f Func) FormatMetricLine(metricLine string, aggrs []string) (string, error)

metric line: $ns/$raw-metric

func (Func) GetAggrsFromArgLines

func (f Func) GetAggrsFromArgLines(argLines string) ([]string, error)

func (Func) HasSameSortedArray

func (f Func) HasSameSortedArray(a [][]string) bool

检查 排序字符串数组数组 a中是否有完全相同的数组

func (Func) IsOk

func (f Func) IsOk(code string) bool

func (Func) IsSubKeys

func (f Func) IsSubKeys(a []string, b map[string]string) bool

检查 a是否为b的keys的子集(subKeys)

func (Func) MergeSortedArrays

func (f Func) MergeSortedArrays(consts, vars [][]string) [][]string

consts不能被修改, vars可以被修改

func (Func) TranslateArgLines

func (f Func) TranslateArgLines(argLines string, aggrNeed ...bool) (map[string]string, string, error)

func (Func) TranslateMetricLine

func (f Func) TranslateMetricLine(metricLine string) ([]string, error)

func (Func) TranslateValueLine

func (f Func) TranslateValueLine(valueLine string) ([]string, error)

value line 拆解为子字符串, 根据协议不同, 每个协议单独对子串进行处理

func (Func) TrimRpcCallee

func (f Func) TrimRpcCallee(callee string) string

type Point

type Point struct {
	Namespace string            `json:"namespace"`
	Name      string            `json:"name"`
	Timestamp int64             `json:"timestamp"`
	Tags      map[string]string `json:"tags"`
	Value     float64           `json:"value"`
	Step      int               `json:"step"`
}

point to n9e-agent

func (*Point) String

func (self *Point) String() string

func (Point) Strings

func (self Point) Strings(points []*Point) string

type StatsdReceiver

type StatsdReceiver struct{}

func (StatsdReceiver) HandlePacket

func (self StatsdReceiver) HandlePacket(packet string)

type StatsdReporter

type StatsdReporter struct{}

func (StatsdReporter) LastPoints

func (self StatsdReporter) LastPoints() []*Point

func (StatsdReporter) Report

func (self StatsdReporter) Report()

type StatsdState

type StatsdState struct{}

func (StatsdState) GetState

func (self StatsdState) GetState() *state

func (StatsdState) RollState

func (self StatsdState) RollState() *state

type TraceHandler

type TraceHandler struct {
	sync.RWMutex
	SecurityScanCounter map[string]float64 // map[ns]counter
}

Jump to

Keyboard shortcuts

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