trace

package
v0.0.7 Latest Latest
Warning

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

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

Documentation

Index

Constants

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

Variables

View Source
var (
	SwitchTrace         = true
	SwitchTraceDatabase = true
	SwitchTraceRedis    = true
	SwitchTraceEtcd     = true
)

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
	//  子rpc id的自增器
	ChildRpcSeq atomic.Int32
	// contains filtered or unexported fields
}

func StartTrace

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

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

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