Documentation
¶
Index ¶
- Constants
- func GenerateID() string
- func RequestIDFromContext(ctx context.Context) string
- func TraceIDFromContext(ctx context.Context) string
- func WithRequestID(ctx context.Context, requestID string) context.Context
- func WithTraceAndRequestID(ctx context.Context, traceID, requestID string) context.Context
- func WithTraceID(ctx context.Context, traceID string) context.Context
Constants ¶
View Source
const ( // TraceIDKey trace ID 在 context 中的 key TraceIDKey = "trace_id" // RequestIDKey request ID 在 context 中的 key RequestIDKey = "request_id" )
Trace and Request ID 相关常量
View Source
const ( // TraceIDHeader trace ID 的 HTTP 头名称 TraceIDHeader = "X-Trace-ID" // RequestIDHeader request ID 的 HTTP 头名称 RequestIDHeader = "X-Request-ID" )
HTTP headers for trace and request IDs
Variables ¶
This section is empty.
Functions ¶
func RequestIDFromContext ¶
RequestIDFromContext 从 context 中提取 request ID
func TraceIDFromContext ¶
TraceIDFromContext 从 context 中提取 trace ID
func WithRequestID ¶
WithRequestID 将 request ID 添加到 context 中
func WithTraceAndRequestID ¶
WithTraceAndRequestID 同时将 trace ID 和 request ID 添加到 context 中
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.