Documentation ¶
Overview ¶
Package trace
Index ¶
- Constants
- func FormatCtx(ctx context.Context) string
- func GenSpanId() string
- func GenTraceId() string
- func GetClientAddr(req *http.Request) string
- func PutTrace(trace *Trace)
- func SetCtxTrace(ctx context.Context, val *Trace) context.Context
- type HintContent
- type HintSampling
- type ICtxKey
- type Trace
- func (tr *Trace) AddHttpHeader(request *http.Request)
- func (tr *Trace) GenSpanId() string
- func (tr *Trace) GetClientAddr(req *http.Request) string
- func (tr *Trace) GetHintCode(req *http.Request) string
- func (tr *Trace) GetHintContent(req *http.Request) string
- func (tr *Trace) GetHttpHost(req *http.Request) string
- func (tr *Trace) GetHttpMethod(req *http.Request) string
- func (tr *Trace) GetHttpParams(req *http.Request) string
- func (tr *Trace) GetHttpURL(req *http.Request) string
- func (tr *Trace) GetSpanId(req *http.Request) string
- func (tr *Trace) GetTraceId(req *http.Request) string
- func (tr *Trace) IsPressureTraffic() bool
- func (tr *Trace) IsTraceSampleEnabled() (hit bool)
- func (tr *Trace) String() string
Constants ¶
View Source
const ( //TraceId DIDI_HEADER_RID = "Didi-Header-Rid" //SpanId DIDI_HEADER_SPANID = "Didi-Header-Spanid" DIDI_HEADER_HINT_CODE = "Didi-Header-Hint-Code" DIDI_HEADER_HINT_CONTENT = "Didi-Header-Hint-Content" EMPRY_TRACE_ID = "" TRACEID = "traceid" SPANID = "spanid" CALLER = "caller" SRC_METHOD = "srcMethod" HINT_CODE = "hintCode" HINT_CONTENT = "hintContent" DLTagUndefined = " _undef" DLTagMysqlFailed = " _com_mysql_failure" DLTagMysqlSuccess = " _com_mysql_success" DLTagRedisFailed = " _com_redis_failure" DLTagRedisSuccess = " _com_redis_success" DLTagThriftFailed = " _com_thrift_failure" DLTagThriftSuccess = " _com_thrift_success" DLTagHTTPSuccess = " _com_http_success" DLTagHTTPFailed = " _com_http_failure" DLTagBackendRPCFailed = " _com_interactive_failure" DLTagRequestIn = " _com_request_in" DLTagRequestOut = " _com_request_out" EMPTY_SPAN_ID string = "0" HINT_PRESSURE_TRAFFIC = "1" HINT_NORMAL_TRAFFIC = "0" HINT_TRACE_SAMPLE_INIT int64 = 0x80 HINT_TRACE_SAMPLE int64 = 0x40 DEFAULT_TRACE_SAMPLE_RATE int64 = 10000 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HintContent ¶
type HintContent struct {
Sample HintSampling `json:"Sample"`
}
type HintSampling ¶
type Trace ¶
type Trace struct { TraceId string SpanId string Caller string SrcMethod string Method string Host string URL string Params string From string HintCode string Sampling int HintContent string FormatString string }
func GetCtxTrace ¶
GetCtxTrace get context *Trace
func NewWithMap ¶
func (*Trace) AddHttpHeader ¶
AddHttpHeader 向http request header中添加trace信息
func (*Trace) GetHintCode ¶
GetHintCode 获取HintCode
func (*Trace) GetHintContent ¶
GetHintContent 获取HintContent
func (*Trace) GetTraceId ¶
GetTraceId 获取TraceId,如果不存在就生成
func (*Trace) IsPressureTraffic ¶
IsPressureTraffic 判断是否是压测流量
func (*Trace) IsTraceSampleEnabled ¶
IsTraceSampleEnabled 判断采样相关逻辑
Click to show internal directories.
Click to hide internal directories.