traffic

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package traffic 统计本进程提供 HTTP 服务时实际读写的正文,不统计协议开销。

Index

Constants

This section is empty.

Variables

View Source
var Default = New()

Functions

This section is empty.

Types

type Counter

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

Counter 用固定大小的时间桶提供滚动速度,避免为每个连接启动采样协程。

func New

func New() *Counter

func (*Counter) Add

func (c *Counter) Add(received, sent int)

func (*Counter) Snapshot

func (c *Counter) Snapshot() Snapshot

type Snapshot

type Snapshot struct {
	StartedAt             time.Time `json:"startedAt"`
	ReceivedBytes         uint64    `json:"receivedBytes"`
	SentBytes             uint64    `json:"sentBytes"`
	ReceiveBytesPerSecond float64   `json:"receiveBytesPerSecond"`
	SendBytesPerSecond    float64   `json:"sendBytesPerSecond"`
}

Jump to

Keyboard shortcuts

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