Documentation ¶
Index ¶
- Constants
- Variables
- func GenLogId() string
- func PushMonitor(ctx context.Context, args ...interface{})
- func PushNotice(ctx context.Context, args ...interface{})
- func PushTrace(ctx context.Context, args ...interface{})
- func SetTraceHeaderByGinContext(ctx context.Context, header map[string]string) map[string]string
- type BDTraceLog
- type ITraceLog
- type LogUnits
- func (p *LogUnits) AddLogUnit(k string, v string)
- func (p *LogUnits) AddLogUnitThreadSafe(k string, v string)
- func (p *LogUnits) AddTimeCost(k string, tNs int64)
- func (p *LogUnits) AddTimeCostThreadSafe(k string, tNs int64)
- func (p *LogUnits) MergeLogUnit(o *LogUnits, prefix string)
- func (p *LogUnits) SerializeTimeCost() string
- func (p *LogUnits) SetBeginTime()
- func (p *LogUnits) SetCmd(cmd string)
- func (p *LogUnits) String() string
- type Monitor
- type Notice
- type Option
- type Trace
- type TraceLog
- type UserContext
Constants ¶
View Source
const ( // 定义spanContext HTTP_KEY_TRACE_ID = "X_bd_logid" HTTP_KEY_SPAN_ID = "X_bd_spanid" // 0.0.0 规则, 此处第一调用为,0.3.0 HTTP_KEY_UNIQ_ID = "X_bd_uniqid" HTTP_KEY_CALLER = "X_bd_module" HTTP_KEY_IDC = "X_bd_idc" HTTP_KEY_CALLER_URI = "X_bd_caller_uri" //osc 限流,此处不设置 HTTP_KEY_SUBSYS = "X_bd_subsys" // 自定义baggage,需全程透传 HTTP_KEY_PRODUCT = "X_bd_product" HTTP_KEY_USERIP = "X_bd_userip" HTTP_USER_AGENT = "User-Agent" )
View Source
const ( TRACECTX = "TRACECTX" TRACELOG = "TRACELOG" )
View Source
const (
MONITORCTX = "MONITORCTX"
)
View Source
const (
NOTICECTX = "NOTICECTX"
)
Variables ¶
View Source
var EmptyTraceLog = &TraceLog{}
View Source
var Project = ""
Functions ¶
func PushMonitor ¶
参数args: [key value]...
Types ¶
type BDTraceLog ¶
type BDTraceLog struct { }
func (*BDTraceLog) SetTraceLogFromGinHeader ¶
func (l *BDTraceLog) SetTraceLogFromGinHeader(c *gin.Context) *TraceLog
type LogUnits ¶
type LogUnits struct {
// contains filtered or unexported fields
}
func (*LogUnits) AddLogUnit ¶
add log unit like bd odp addNotice
func (*LogUnits) AddLogUnitThreadSafe ¶
multi go routine safe add
func (*LogUnits) AddTimeCost ¶
func (*LogUnits) AddTimeCostThreadSafe ¶
multi go routine 版本
func (*LogUnits) MergeLogUnit ¶
func (*LogUnits) SerializeTimeCost ¶
func (*LogUnits) SetBeginTime ¶
func (p *LogUnits) SetBeginTime()
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
func GetMonitorFromContext ¶
type Notice ¶
type Notice struct {
// contains filtered or unexported fields
}
func GetNoticeFromContext ¶
type TraceLog ¶
type TraceLog struct { SpanNum atomic.Int64 //用于计算本地spanId自增拼接 LogId string SpanId string UniqId string UserIP string Product string Caller string Refer string Path string // 当前请求的地址,用作请求下游时,设置成refer MqTransId string //mq tranId 比如mq push模式 push uri地址参数中会有带上事务id }
func GetTraceLogFromContext ¶
从context中获取span信息集合
func GetTraceLogFromGinContext ¶
从gin context中获取span信息集合
func (*TraceLog) FormatTraceString ¶
func (*TraceLog) GetCurrentSpanId ¶
type UserContext ¶
func CtxTransfer ¶
func CtxTransfer(ctx context.Context, key string) *UserContext
func NewUserContext ¶
func NewUserContext(opts ...Option) *UserContext
func (*UserContext) Clone ¶
func (this *UserContext) Clone() *UserContext
gin.Context 属于对象池,因此在异步执行时,需要拷贝一个再使用.注:在多个goroutine中,应使用线程安全的AddLogUnit方法
func (*UserContext) SetErr ¶
func (this *UserContext) SetErr(err error)
Click to show internal directories.
Click to hide internal directories.