stat

package
v0.0.0-...-115e584 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWriteFailed = errors.New("submit failed")

ErrWriteFailed 提交StatReport失败

Functions

func CpuUsage

func CpuUsage() int64

CpuUsage 返回当前的cpu使用率

func DisableLog

func DisableLog()

DisableLog 关闭stats的日志

func Report

func Report(msg string)

Report 报告给定的message

func SetReportWriter

func SetReportWriter(writer Writer)

SetReportWriter 设置report writer

func SetReporter

func SetReporter(fn func(string))

SetReporter 设置reporter

Types

type Metrics

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

Metrics 用于记录和报告统计报告

func NewMetrics

func NewMetrics(name string) *Metrics

NewMetrics 返回Metrics实例

func (*Metrics) Add

func (m *Metrics) Add(task Task)

Add 添加task

func (*Metrics) AddDrop

func (m *Metrics) AddDrop()

AddDrop 添加drop

func (*Metrics) SetName

func (m *Metrics) SetName(name string)

SetName 设置m的名字

type RemoteWriter

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

RemoteWriter 写入StatReport的writer

func (*RemoteWriter) Write

func (rw *RemoteWriter) Write(report *StatReport) error

type StatReport

type StatReport struct {
	Name          string  `json:"name"`
	Timestamp     int64   `json:"tm"`
	Pid           int     `json:"pid"`
	ReqsPerSecond float32 `json:"qps"`
	Drops         int     `json:"drops"`
	Average       float32 `json:"avg"`
	Median        float32 `json:"med"`
	Top90th       float32 `json:"t90"`
	Top99th       float32 `json:"t99"`
	Top99p9th     float32 `json:"t99p9"`
}

StatReport 使用stat报告的基本单元

type Task

type Task struct {
	Drop        bool
	Duration    time.Duration
	Description string
}

Task 报告Metrics的task

type Writer

type Writer interface {
	Write(report *StatReport) error
}

Writer 包装Write方法的接口

func NewRemoteWriter

func NewRemoteWriter(endpoint string) Writer

NewRemoteWriter 返回RemoteWriter实例

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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