metrics

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metrics

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

A Metrics is used to log and report stat reports.

func NewMetrics

func NewMetrics(name string) *Metrics

NewMetrics returns a Metrics.

func (*Metrics) Add

func (m *Metrics) Add(task barrier.Task)

type PeriodicalExecutor

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

PeriodicalExecutor 是一个周期性执行任务的执行器。

func NewPeriodicalExecutor

func NewPeriodicalExecutor(interval time.Duration, container TaskContainer) *PeriodicalExecutor

NewPeriodicalExecutor returns a PeriodicalExecutor with given interval and container.

func (*PeriodicalExecutor) Add

func (pe *PeriodicalExecutor) Add(task interface{})

Add 追加一个任务

func (*PeriodicalExecutor) Flush

func (pe *PeriodicalExecutor) Flush() bool

Flush 强制执行任务

type StatReport

type StatReport struct {
	Name          string  `json:"name" description:"任务名称"`
	Timestamp     int64   `json:"tm" description:"统计报告的时间戳,表示报告生成的时间"`
	Pid           int     `json:"pid" description:"进程的ID,用于标识生成报告的进程"`
	ReqsPerSecond float32 `json:"qps" description:"每秒请求数,表示任务的平均每秒请求数量。"`
	Drops         int     `json:"drops"` //Drops:丢弃数,表示任务被丢弃的次数。
	Average       float32 `json:"avg"`   //Average:平均耗时,表示任务的平均执行时间。
	Median        float32 `json:"med"`   //Median:中位数耗时,表示任务执行时间的中间值,即将任务按照执行时间排序后,位于中间位置的任务的执行时间。
	Top90th       float32 `json:"t90"`   //Top90th:90% 耗时,表示任务执行时间的第 90 百分位数,即将任务按照执行时间排序后,位于前 90% 的任务的执行时间。
	Top99th       float32 `json:"t99"`   //Top99th:99% 耗时,表示任务执行时间的第 99 百分位数,即将任务按照执行时间排序后,位于前 99% 的任务的执行时间。
	Top99p9th     float32 `json:"t99p9"` //Top99p9th:99.9% 耗时,表示任务执行时间的第 99.9 百分位数,即将任务按照执行时间排序后,位于前 99.9% 的任务的执行时间。
}

StatReport is a stat report entry.

type TaskContainer

type TaskContainer interface {
	// AddTask adds the task into the container. 如果添加后需要刷新,则返回true
	AddTask(task interface{}) bool
	// Execute 在刷新容器时,处理容器中收集到的任务。
	Execute(tasks interface{})
	// RemoveAll 移除容器中包含的任务,并将它们返回。
	RemoveAll() interface{}
}

type Writer

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

StatReport is a stat report entry.

Jump to

Keyboard shortcuts

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