Files
go-gin-api/internal/proposal/alert.go
新亮 4c37a7e6b5 feature(1.2.8): swagger 接口文档新增 Security
- 将 middleware 命名为 interceptor
- 将 deploy 命名为 deployments
- 移除 pkg/errno
- 使用 proposal 目录
- 优化代码
2021-11-28 13:25:27 +08:00

29 lines
950 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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)