Documentation
¶
Index ¶
- Constants
- type Cache
- type D
- type Debug
- type Dialog
- type Request
- type Response
- type SQL
- type T
- type Trace
- func (t *Trace) AppendCache(Cache *Cache) *Trace
- func (t *Trace) AppendDebug(debug *Debug) *Trace
- func (t *Trace) AppendDialog(dialog *Dialog) *Trace
- func (t *Trace) AppendSQL(sql *SQL) *Trace
- func (t *Trace) ID() string
- func (t *Trace) SetAlwaysTrace(b bool)
- func (t *Trace) SetLogger(logger *zap.Logger)
- func (t *Trace) WithRequest(req *Request) *Trace
- func (t *Trace) WithResponse(resp *Response) *Trace
Constants ¶
View Source
const Header = "TRACE-ID"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
Name string `json:"name"` //缓存组件名
TraceTime string `json:"trace_time"` // 时间,格式:2006-01-02 15:04:05
CMD string `json:"cmd"` // 操作,SET/GET 等
Key string `json:"key"` // Key
Value interface{} `json:"value,omitempty"` // Value
TTL float64 `json:"ttl,omitempty"` // 超时时长(单位分)
CostMillisecond int64 `json:"cost_millisecond"` // 执行时长(单位ms)
SlowLoggerMillisecond int64 `json:"slow_logger_millisecond"` //慢查记录时间
Logger *zap.Logger `json:"-"`
AlwaysTrace bool `json:"always_trace"`
}
type Debug ¶
type Debug struct {
Key string `json:"key"` // 标示
Value interface{} `json:"value"` // 值
CostMillisecond int64 `json:"cost_millisecond"` // 执行时长(单位ms)
Logger *zap.Logger `json:"-"`
}
Debug 自定义调试信息
type Dialog ¶
type Dialog struct {
Request *Request `json:"request"` // 请求信息
Responses []*Response `json:"responses"` // 返回信息
Success bool `json:"success"` // 是否成功,true 或 false
CostMillisecond int64 `json:"cost_millisecond"` // 执行时长(单位ms)
Logger *zap.Logger `json:"-"`
AlwaysTrace bool `json:"always_trace"`
// contains filtered or unexported fields
}
Dialog 内部调用其它方接口的会话信息;失败时会有retry操作,所以 response 会有多次。
func (*Dialog) AppendResponse ¶
AppendResponse 按转的追加response信息
type Request ¶
type Request struct {
TTL string `json:"ttl"` // 请求超时时间
Method string `json:"method"` // 请求方式
DecodedURL string `json:"decoded_url"` // 请求地址
Header interface{} `json:"header"` // 请求 Header 信息
Body interface{} `json:"body"` // 请求 Body 信息
Logger *zap.Logger `json:"-"`
AlwaysTrace bool `json:"always_trace"`
}
Request 请求信息
type Response ¶
type Response struct {
Header interface{} `json:"header"` // Header 信息
Body interface{} `json:"body"` // Body 信息
BusinessCode int `json:"business_code,omitempty"` // 业务码
BusinessCodeMsg string `json:"business_code_msg,omitempty"` // 提示信息
HttpCode int `json:"http_code"` // HTTP 状态码
HttpCodeMsg string `json:"http_code_msg"` // HTTP 状态码信息
CostMillisecond int64 `json:"cost_millisecond"` // 执行时间(单位ms)
Logger *zap.Logger `json:"-"`
AlwaysTrace bool `json:"always_trace"`
}
Response 响应信息
type SQL ¶
type SQL struct {
TraceTime string `json:"trace_time"` // 时间,格式:2006-01-02 15:04:05
Stack string `json:"stack"` // 文件地址和行号
SQL string `json:"sql"` // SQL 语句
AffectedRows int64 `json:"affected_rows"` // 影响行数
CostMillisecond int64 `json:"cost_millisecond"` // 执行时长(单位ms)
SlowLoggerMillisecond int64 `json:"slow_logger_millisecond"` //慢查记录时间
Logger *zap.Logger `json:"-"`
AlwaysTrace bool `json:"always_trace"`
}
type Trace ¶
type Trace struct {
Identifier string `json:"trace_id"` // 链路ID
Request *Request `json:"request"` // 请求信息
Response *Response `json:"response"` // 返回信息
ThirdPartyRequests []*Dialog `json:"third_party_requests"` // 调用第三方接口的信息
Debugs []*Debug `json:"debugs"` // 调试信息
SQLs []*SQL `json:"sqls"` // 执行的 SQL 信息
Cache []*Cache `json:"Cache"` // 执行的 Cache 信息
Success bool `json:"success"` // 请求结果 true or false
CostMillisecond float64 `json:"cost_millisecond"` // 执行时长(单位ms)
Logger *zap.Logger `json:"-"`
AlwaysTrace bool `json:"always_trace"`
// contains filtered or unexported fields
}
Trace 记录的参数
func (*Trace) AppendDialog ¶
AppendDialog 安全的追加内部调用过程dialog
func (*Trace) WithResponse ¶
WithResponse 设置response
Click to show internal directories.
Click to hide internal directories.