mirror of
https://github.com/LLiuHuan/gin-template.git
synced 2025-12-24 13:37:58 +08:00
35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
// Package proposal
|
||
//
|
||
// @program: gin-template
|
||
// @author: [lliuhuan](https://github.com/lliuhuan)
|
||
// @create: 2024-07-02 21:40
|
||
// @description: 告警信息
|
||
package proposal
|
||
|
||
import (
|
||
"encoding/json"
|
||
"time"
|
||
)
|
||
|
||
// AlertMessage 告警信息
|
||
type AlertMessage struct {
|
||
ProjectName string `json:"project_name"` // 项目名,用于区分不同项目告警信息
|
||
Env string `json:"env"` // 运行环境
|
||
TraceID string `json:"trace_id"` // 唯一ID,用于追踪关联
|
||
HOST string `json:"host"` // 请求 HOST
|
||
URI string `json:"uri"` // 请求 URI
|
||
Method string `json:"method"` // 请求 Method
|
||
ErrorMessage interface{} `json:"error_message"` // 错误信息
|
||
ErrorStack string `json:"error_stack"` // 堆栈信息
|
||
Timestamp time.Time `json:"timestamp"` // 时间戳
|
||
}
|
||
|
||
// Marshal 序列化到JSON
|
||
func (a *AlertMessage) Marshal() (jsonRaw []byte) {
|
||
jsonRaw, _ = json.Marshal(a)
|
||
return
|
||
}
|
||
|
||
// NotifyHandler 告警的发送句柄
|
||
type NotifyHandler func(msg *AlertMessage)
|