trace

package
v0.0.0-...-e5d1c0a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const Header = "TRACE-ID"

Variables

This section is empty.

Functions

This section is empty.

Types

type D

type D interface {
	AppendResponse(resp *Response)
	// contains filtered or unexported methods
}

type Debug

type Debug struct {
	Key         string      `json:"key"`          // 标示
	Value       interface{} `json:"value"`        // 值
	CostSeconds float64     `json:"cost_seconds"` // 执行时间(单位秒)
}

type Redis

type Redis struct {
	Timestamp   string  `json:"timestamp"`       // 时间,格式:2006-01-02 15:04:05
	Handle      string  `json:"handle"`          // 操作,SET/GET 等
	Key         string  `json:"key"`             // Key
	Value       string  `json:"value,omitempty"` // Value
	TTL         float64 `json:"ttl,omitempty"`   // 超时时长(单位分)
	CostSeconds float64 `json:"cost_seconds"`    // 执行时间(单位秒)
}

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 信息
}

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 状态码信息
	CostSeconds     float64     `json:"cost_seconds"`                // 执行时间(单位秒)
}

Response 响应信息

type SQL

type SQL struct {
	Timestamp   string  `json:"timestamp"`     // 时间,格式:2006-01-02 15:04:05
	Stack       string  `json:"stack"`         // 文件地址和行号
	SQL         string  `json:"sql"`           // SQL 语句
	Rows        int64   `json:"rows_affected"` // 影响行数
	CostSeconds float64 `json:"cost_seconds"`  // 执行时长(单位秒)
}

type T

type T interface {
	ID() string
	WithRequest(req *Request) *Trace
	WithResponse(resp *Response) *Trace
	AppendDialog(dialog *Treq) *Trace
	AppendSQL(sql *SQL) *Trace
	AppendRedis(redis *Redis) *Trace
	// contains filtered or unexported methods
}

type Trace

type Trace struct {
	Identifier         string    `json:"trace_id"`             // 链路ID
	Request            *Request  `json:"request"`              // 请求信息
	Response           *Response `json:"response"`             // 返回信息
	ThirdPartyRequests []*Treq   `json:"third_party_requests"` // 调用第三方接口的信息
	Debugs             []*Debug  `json:"debugs"`               // 调试信息
	SQLs               []*SQL    `json:"sqls"`                 // 执行的 SQL 信息
	Redis              []*Redis  `json:"redis"`                // 执行的 Redis 信息
	Success            bool      `json:"success"`              // 请求结果 true or false
	CostSeconds        float64   `json:"cost_seconds"`         // 执行时长(单位秒)
	// contains filtered or unexported fields
}

Trace 记录的参数

func New

func New(id string) *Trace

func (*Trace) AppendDebug

func (t *Trace) AppendDebug(debug *Debug) *Trace

AppendDebug 追加 debug

func (*Trace) AppendDialog

func (t *Trace) AppendDialog(dialog *Treq) *Trace

AppendDialog 安全的追加内部调用过程Treq

func (*Trace) AppendRedis

func (t *Trace) AppendRedis(redis *Redis) *Trace

AppendRedis 追加 Redis

func (*Trace) AppendSQL

func (t *Trace) AppendSQL(sql *SQL) *Trace

AppendSQL 追加 SQL

func (*Trace) ID

func (t *Trace) ID() string

ID 唯一标识符

func (*Trace) WithRequest

func (t *Trace) WithRequest(req *Request) *Trace

WithRequest 设置request

func (*Trace) WithResponse

func (t *Trace) WithResponse(resp *Response) *Trace

WithResponse 设置response

type Treq

type Treq struct {
	Request     *Request    `json:"request"`      // 请求信息
	Responses   []*Response `json:"responses"`    // 返回信息
	Success     bool        `json:"success"`      // 是否成功,true 或 false
	CostSeconds float64     `json:"cost_seconds"` // 执行时长(单位秒)
	// contains filtered or unexported fields
}

Treq 内部调用其它方接口的会话信息;失败时会有retry操作,所以 response 会有多次。

func (*Treq) AppendResponse

func (d *Treq) AppendResponse(resp *Response)

AppendResponse 按转的追加response信息

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL