monitor

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package monitor collect and export openapi metrics

Package monitor collect and export openapi metrics

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Metrics

func Metrics(rw http.ResponseWriter, req *http.Request)

Metrics 返回单调递增的 openapi metrics

func Notify

func Notify(info Info)

Notify 使用默认 Monitor 调用 Notify

func Stat

func Stat(rw http.ResponseWriter, req *http.Request)

Stat 返回所收集的 openapi 状态

Types

type Info

type Info struct {
	Tp     InfoType
	Detail string
	Value  int64
}

Info monitor 使用处需要提供的信息

type InfoType

type InfoType int

InfoType metric 分类

const (
	// AuthFail auth 失败
	AuthFail InfoType = iota
	// AuthSucc auth 成功
	AuthSucc
	// APIInvokeCount api 调用次数
	APIInvokeCount
	// APIInvokeDuration api 调用时长
	APIInvokeDuration
	// API50xCount api 5xx 次数
	API50xCount
	// API40xCount api 4xx 次数
	API40xCount
	// LastType InfoType 个数
	LastType
)

func (InfoType) String

func (i InfoType) String() string

type Monitor

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

Monitor monitor struct

func New

func New() (*Monitor, error)

New 创建 Monitor

func (*Monitor) Notify

func (m *Monitor) Notify(info Info)

Notify monitor 使用处调用这个接口

Jump to

Keyboard shortcuts

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