httpstat

package
v2.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package httpstat implements the statistics tool for HTTP traffic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPStat

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

HTTPStat is the statistics tool for HTTP traffic.

func New

func New() *HTTPStat

New creates an HTTPStat.

func (*HTTPStat) Stat

func (hs *HTTPStat) Stat(m *Metric)

Stat stats the ctx.

func (*HTTPStat) Status

func (hs *HTTPStat) Status() *Status

Status returns HTTPStat Status, It assumes it is called every five seconds. https://github.com/rcrowley/go-metrics/blob/3113b8401b8a98917cde58f8bbd42a1b1c03b1fd/ewma.go#L98-L99

type Item

type Item struct {
	Path string `json:"path"`
	*Status
}

Item is the item of status.

type Metric

type Metric struct {
	StatusCode int
	Duration   time.Duration
	ReqSize    uint64
	RespSize   uint64
}

Metric is the package of statistics at once.

type RequestMetric

type RequestMetric struct {
	Count uint64  `json:"count"`
	M1    float64 `json:"m1"`
	M5    float64 `json:"m5"`
	M15   float64 `json:"m15"`

	ErrCount uint64  `json:"errCount"`
	M1Err    float64 `json:"m1Err"`
	M5Err    float64 `json:"m5Err"`
	M15Err   float64 `json:"m15Err"`

	M1ErrPercent  float64 `json:"m1ErrPercent"`
	M5ErrPercent  float64 `json:"m5ErrPercent"`
	M15ErrPercent float64 `json:"m15ErrPercent"`

	Min  uint64 `json:"min"`
	Max  uint64 `json:"max"`
	Mean uint64 `json:"mean"`

	P25  float64 `json:"p25"`
	P50  float64 `json:"p50"`
	P75  float64 `json:"p75"`
	P95  float64 `json:"p95"`
	P98  float64 `json:"p98"`
	P99  float64 `json:"p99"`
	P999 float64 `json:"p999"`

	ReqSize  uint64 `json:"reqSize"`
	RespSize uint64 `json:"respSize"`
}

RequestMetric contains request metrics.

type Status

type Status struct {
	RequestMetric
	Codes map[int]uint64 `json:"codes"`
}

Status contains all status generated by HTTPStat.

func (*Status) ToMetrics

func (s *Status) ToMetrics(service string) []*easemonitor.Metrics

ToMetrics implements easemonitor.Metricer.

type StatusCodeMetric

type StatusCodeMetric struct {
	Code  int    `json:"code"`
	Count uint64 `json:"cnt"`
}

StatusCodeMetric is the metrics of http status code.

type TopN

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

TopN is the statistics tool for HTTP traffic.

func NewTopN

func NewTopN(n int) *TopN

NewTopN creates a TopN.

func (*TopN) Stat

func (t *TopN) Stat(path string) *HTTPStat

Stat stats the ctx.

func (*TopN) Status

func (t *TopN) Status() []*Item

Status returns TopN Status, and resets all metrics.

Jump to

Keyboard shortcuts

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