Documentation ¶
Index ¶
- Constants
- Variables
- func GetMeshKeys() []string
- func ToMap(ctx XContext) map[string]string
- type BizTrace
- type EmptyContext
- func (ctx *EmptyContext) Deadline() (deadline time.Time, ok bool)
- func (ctx *EmptyContext) Done() <-chan struct{}
- func (ctx *EmptyContext) Err() error
- func (ctx *EmptyContext) Get(key string) (value interface{}, exist bool)
- func (ctx *EmptyContext) GetBizTrace() BizTrace
- func (ctx *EmptyContext) GetLang() LangInfo
- func (ctx *EmptyContext) GetMeshTrace() MeshTrace
- func (ctx *EmptyContext) GetProtocol() ProtocolType
- func (ctx *EmptyContext) GetRasseTrace() RasseTrace
- func (ctx *EmptyContext) GetRawContext() interface{}
- func (ctx *EmptyContext) GetUserInfo() UserInfo
- func (ctx *EmptyContext) Set(key string, value interface{})
- func (ctx *EmptyContext) Value(key interface{}) interface{}
- type LangInfo
- type MeshTrace
- type ProtocolType
- type RasseTrace
- type UserInfo
- type XContext
Constants ¶
View Source
const ( // 统一前缀 RASSE_PREFIX = "x-rasse-" // 业务链路跟踪Key BIZ_TRACE_KEY = RASSE_PREFIX + "biz-id" // 用户信息 USER_KEY = RASSE_PREFIX + "user" // 用户信息 USERNAME_KEY = RASSE_PREFIX + "user-name" // 用户信息 USERID_KEY = RASSE_PREFIX + "user-id" // 请求唯一ID RASSE_TRACE_KEY = RASSE_PREFIX + "trace-id" // 全链路跟踪配置 MESH_CONFIG_KEY = "mesh.headers" // 多语言 LANG_KEY = RASSE_PREFIX + "lang" )
Variables ¶
View Source
var DEFAULT_LANG = "zh-CN"
参考规范:https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Language
View Source
var DEFAULT_MESH_TRACE_KEYS = []string{
"x-request-id",
"x-b3-traceid",
"x-b3-spanid",
"x-b3-parentspanid",
"x-b3-sampled",
"x-b3-flags",
"x-ot-span-xcontext",
"x-envoy-attempt-count",
"x-envoy-external-address",
"x-envoy-original-path"}
默认的Mesh 的APM KEY
Functions ¶
func GetMeshKeys ¶
func GetMeshKeys() []string
Types ¶
type EmptyContext ¶
type EmptyContext struct { RawContext context.Context Protocol ProtocolType Trace RasseTrace Mesh MeshTrace User UserInfo Biz BizTrace Lang LangInfo }
EmptyContext
func (*EmptyContext) Done ¶
func (ctx *EmptyContext) Done() <-chan struct{}
func (*EmptyContext) Err ¶
func (ctx *EmptyContext) Err() error
func (*EmptyContext) Get ¶
func (ctx *EmptyContext) Get(key string) (value interface{}, exist bool)
func (*EmptyContext) GetBizTrace ¶
func (ctx *EmptyContext) GetBizTrace() BizTrace
func (*EmptyContext) GetLang ¶
func (ctx *EmptyContext) GetLang() LangInfo
func (*EmptyContext) GetMeshTrace ¶
func (ctx *EmptyContext) GetMeshTrace() MeshTrace
func (*EmptyContext) GetProtocol ¶
func (ctx *EmptyContext) GetProtocol() ProtocolType
func (*EmptyContext) GetRasseTrace ¶
func (ctx *EmptyContext) GetRasseTrace() RasseTrace
func (*EmptyContext) GetRawContext ¶
func (ctx *EmptyContext) GetRawContext() interface{}
===== rasseContext start ======
func (*EmptyContext) GetUserInfo ¶
func (ctx *EmptyContext) GetUserInfo() UserInfo
func (*EmptyContext) Set ¶
func (ctx *EmptyContext) Set(key string, value interface{})
func (*EmptyContext) Value ¶
func (ctx *EmptyContext) Value(key interface{}) interface{}
type ProtocolType ¶
type ProtocolType int32
协议
const ( Gin ProtocolType Trpc Test TDMQ )
func (ProtocolType) String ¶
func (p ProtocolType) String() string
type RasseTrace ¶
type RasseTrace string
type XContext ¶
type XContext interface { context.Context // 获取原生的context GetRawContext() interface{} // 获取当前协议 GetProtocol() ProtocolType // 获取全链路跟踪信息 GetMeshTrace() MeshTrace // 获取请求跟踪信息 GetRasseTrace() RasseTrace // 获取用户信息 GetUserInfo() UserInfo // 获取语言信息 GetLang() LangInfo // 获取业务链路跟踪信息 GetBizTrace() BizTrace // 从上下文中获取内容 Get(key string) (value interface{}, exist bool) // 给上下文赋值 Set(key string, value interface{}) }
rasse 上下文,与协议无关。
Click to show internal directories.
Click to hide internal directories.