metrics

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Float

type Float = expvar.Float

Float 浮點數度量

type Int

type Int = expvar.Int

Int 整數度量

type Map

type Map = expvar.Map

Map 映射度量

type Metricsmgr

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

Metricsmgr 度量管理器, 其中包括兩部分: 效能數據(來自pprof), 自訂度量或度量數據(來自expvar)

如果想查看效能數據, 可以參考以下網址

如果想建立自訂度量, 執行 NewInt, NewFloat, NewString, NewMap, 就可以獲得自訂記錄器; 如果想建立執行度量, 執行 NewRuntime 就可以獲得執行記錄器

如果想查看自訂度量或度量數據, 可以從 https://github.com/divan/expvarmon 安裝expvarmon工具; 工具參數說明如下:

  • ports="http://網址:埠號"
  • vars="監控名稱:記錄名稱,..."
  • i 間隔時間

如果想用expvarmon工具查看執行度量數據, 假設執行記錄器的名稱為'echo', 則改變var參數為 vars="time:echo.time,time(max):echo.time(max),time(avg):echo.time(avg),count:echo.count,count(1m):echo.count(1m),count(5m):echo.count(5m),count(10m):echo.count(10m),count(60m):echo.count(60m)"

expvarmon範例如下:

func NewMetricsmgr

func NewMetricsmgr() *Metricsmgr

NewMetricsmgr 建立度量管理器

func (*Metricsmgr) Finalize

func (this *Metricsmgr) Finalize()

Finalize 結束處理

func (*Metricsmgr) Initialize

func (this *Metricsmgr) Initialize(port int) error

Initialize 初始化處理

func (*Metricsmgr) NewFloat

func (this *Metricsmgr) NewFloat(name string) *Float

NewFloat 建立浮點數度量

func (*Metricsmgr) NewInt

func (this *Metricsmgr) NewInt(name string) *Int

NewInt 建立整數度量

func (*Metricsmgr) NewMap

func (this *Metricsmgr) NewMap(name string) *Map

NewMap 建立映射度量

func (*Metricsmgr) NewRuntime

func (this *Metricsmgr) NewRuntime(name string) *Runtime

NewRuntime 建立執行度量

func (*Metricsmgr) NewString

func (this *Metricsmgr) NewString(name string) *String

NewString 建立字串度量

type Runtime

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

Runtime 執行度量, 記錄了以下數據

  • 總執行時間
  • 最大執行時間
  • 總執行次數
  • 每分鐘執行次數
  • 每5分鐘執行次數
  • 每10分鐘執行次數
  • 每60分鐘執行次數

func (*Runtime) Add

func (this *Runtime) Add(delta time.Duration)

Add 新增記錄

func (*Runtime) Rec

func (this *Runtime) Rec() func()

Rec 執行記錄, 使用時把回傳的函式指標記錄下來, 直到執行區間結束再執行

func (*Runtime) String

func (this *Runtime) String() string

String 取得字串

type String

type String = expvar.String

String 字串度量

Jump to

Keyboard shortcuts

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