Files
gin-template/internal/proposal/alter.go

35 lines
1.1 KiB
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
//
// @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)