Documentation
¶
Overview ¶
Package correlation provides correlation ID propagation via context.
Index ¶
Constants ¶
const MaxIDLen = 255
MaxIDLen is the maximum number of characters accepted for an incoming correlation ID. Longer values are treated as absent by Sanitize.
Variables ¶
This section is empty.
Functions ¶
func ExtractFromContext ¶
ExtractFromContext returns the correlation ID stored in ctx, or an empty string if none is present.
func InjectToContext ¶
InjectToContext returns a copy of ctx with the correlation ID set.
func Sanitize ¶ added in v2.58.0
Sanitize returns id trimmed of surrounding whitespace when it is a valid correlation ID, or a freshly generated UUID otherwise. An ID is valid when it is non-empty, at most MaxIDLen characters, and consists only of [a-zA-Z0-9_-]. This prevents log injection and downstream poisoning from caller-supplied values.
Transport packages (httpserver, grpcserver) apply this to the incoming header so every transport enforces the same rule.
Types ¶
This section is empty.