Documentation
¶
Index ¶
- func FromTraceId(ctx context.Context) string
- func GetTraceId(c *gin.Context) string
- func InjectNewFromTraceId(ctx, newCtx context.Context) context.Context
- func NextTraceId() string
- func TraceId(opts ...Option) gin.HandlerFunc
- func WithTraceId(ctx context.Context, traceId string) context.Context
- type Config
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromTraceId ¶
FromTraceId returns a trace id from the given context if one is present. Returns the empty string if a trace id cannot be found.
func InjectNewFromTraceId ¶ added in v0.3.4
func NextTraceId ¶ added in v0.3.4
func NextTraceId() string
NextTraceId next returns the trace id, which use ulid.
func TraceId ¶
func TraceId(opts ...Option) gin.HandlerFunc
TraceId is a middleware that injects a trace id into the context of each request. if it is empty, set to write head
- traceIdHeader is the name of the HTTP Header which contains the trace id. Exported so that it can be changed by developers. (default "X-Trace-Id")
- nextTraceID generates the next trace id.(default NewSequence function use utilities/sequence)
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config defines the config for TraceId middleware
type Option ¶
type Option func(*Config)
Option TraceId option
func WithNextTraceId ¶
WithNextTraceId optional next trace id function (default NewSequence function use utilities/sequence)
func WithTraceIdHeader ¶
WithTraceIdHeader optional request id header (default "X-Trace-Id")
Click to show internal directories.
Click to hide internal directories.