trace

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SPLIT    = "|"
	NULL_TAG = "-"
)
View Source
const ROOT_RPC_ID = "0"

Variables

This section is empty.

Functions

func Close

func Close()

func EndTrace

func EndTrace(tracer *Tracer, status _const.TraceStatusEnum, message string, responseSize int)

func GetFrontIP

func GetFrontIP(head *http.Header, remoteAddr string) string

func SendTraceLog

func SendTraceLog(tracer *Tracer)

func TracerIsEnable

func TracerIsEnable() bool

Types

type Tracer

type Tracer struct {
	// TraceId 调用链ID,一旦初始化,不能修改
	TraceId string
	// RpcId 调用顺序,依次为0 → 0.1 → 0.1.1,1 -> 1.1 -> 1.1.1 ...
	RpcId string
	// TraceType 链路跟踪类型
	TraceType _const.TraceTypeEnum
	/**
	 * 名称
	 * 可以是一个 http url
	 * 可以是一个rpc的 service.name
	 * 可以是一个MQ的 send.{topic}.{partition}
	 * 可以是访问redis的 get.{namespace}.{key}
	 */
	TraceName string
	// Endpoint 跟踪类型
	Endpoint _const.EndpointEnum

	// RemoteStatus 远程调用结果
	RemoteStatus _const.TraceStatusEnum
	// RemoteIp 远程调用IP,即下游(Client)或上游(Server)ip
	RemoteIp string

	// Size 响应体大小
	Size int

	// StartTime 当前span开始时间
	StartTime int64

	// 是否采样
	Sampled bool

	// 是否已经结束
	Ended bool
	// AttrMap 请求参数
	AttrMap map[string]string
	// contains filtered or unexported fields
}

func ClientStartTrace

func ClientStartTrace(traceType _const.TraceTypeEnum, traceName string) *Tracer

ClientStartTrace 开启客户端跟踪(如前端访问某个后端接口a, 接口a内访问其他接口b, 此时a访问b称为客户端, b接口内为服务端)

func ClientStartTraceWithHeader

func ClientStartTraceWithHeader(header *http.Header, traceName string) *Tracer

func ClientStartTraceWithRequest

func ClientStartTraceWithRequest(req *http.Request) *Tracer

func ServerStartTrace

func ServerStartTrace(traceType _const.TraceTypeEnum, traceName string) *Tracer

ServerStartTrace * traceName 名称

可以是一个 http url
可以是一个rpc的 service.name
可以是一个MQ的 send.{topic}.{partition}
可以是访问redis的 get.{namespace}.{key}

func StartTrace

func StartTrace(traceType _const.TraceTypeEnum, endPoint _const.EndpointEnum, traceName string, header *http.Header) *Tracer

func (*Tracer) EndTrace

func (tracer *Tracer) EndTrace(status _const.TraceStatusEnum, message string, responseSize int)

Jump to

Keyboard shortcuts

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