Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
70 lines
1.3 KiB
Go
70 lines
1.3 KiB
Go
package monitor
|
|
|
|
import "time"
|
|
|
|
type APIStatis struct {
|
|
//路径
|
|
Path string `json:"path"`
|
|
//消耗最大时间rawdata
|
|
MaxTimeRawData string `json:"maxTimeRawData"`
|
|
//调用次数
|
|
CallNum int64 `json:"callNum"`
|
|
//最小耗时
|
|
MinTime int64 `json:"minTime"`
|
|
//最大耗时
|
|
MaxTime int64 `json:"maxTime"`
|
|
//总耗时
|
|
TotalTime int64 `json:"totalTime"`
|
|
//每次调用时间
|
|
TimePerCall int64 `json:"timePerCall"`
|
|
//每秒调用次数
|
|
CallPerSec int64 `json:"callPerSec"`
|
|
//开始时间
|
|
Start time.Time `json:"start"`
|
|
//是否发送过报警
|
|
Send int `json:"send"`
|
|
}
|
|
|
|
// APIStatis 接口统计
|
|
// 每天统计数
|
|
type LogicStatis struct {
|
|
//API总调用次数
|
|
ApiCallNum int64
|
|
//API调用总耗时
|
|
ApiTotalTime int64
|
|
//开始时间
|
|
Start time.Time
|
|
//接口访问次数
|
|
ApisStatis map[string]*APIStatis
|
|
}
|
|
|
|
type SPType string
|
|
|
|
const (
|
|
SP_ApiCall SPType = "apicall"
|
|
SP_GetStatis SPType = "getStatis"
|
|
)
|
|
|
|
// StatisReq 统计请求数据格式
|
|
type AppStatisReq struct {
|
|
Time time.Time `json:"time"`
|
|
//获取的api数量
|
|
ApiNum int64 `json:"apiNum"`
|
|
}
|
|
|
|
type StatisParam struct {
|
|
//调用类型
|
|
Type SPType
|
|
Param1 string
|
|
Param2 int64
|
|
Param3 string
|
|
}
|
|
|
|
var (
|
|
hourStatises map[string]*LogicStatis
|
|
muniteStatises map[string]*LogicStatis
|
|
//api调用参数
|
|
apiCallChan chan *StatisParam
|
|
//退出
|
|
)
|