Documentation
¶
Overview ¶
Package requestid gives every gateway request one id of AI Studio's own.
The id is minted once, at the gateway's entry (Studio's proxy handler, the Microgateway's first middleware), and travels in the request context under the "request_id" key that plugins, hooks, filters and analytics already read. It is returned to the client in Header, never in X-Request-ID, which belongs to the client and to whatever proxies sit in front of the gateway: their X-Request-ID is passed through untouched and recorded as the client request id.
Ids look like "tyai_0192d8a4f6b37c1e9a5b2d4c6e8f0a1b": a fixed prefix, then a UUIDv7 in hex. UUIDv7 is ordered by time and carries 74 random bits, so ids minted on different nodes (edges, Studio replicas) do not collide; the prefix tells them apart from other systems' ids in shared logs.
Index ¶
Constants ¶
const ( // Header carries the gateway's request id on every response, and on the // gateway's own loopback hop, where it is trusted only from that hop. Header = "X-Tyk-AI-Request-ID" // ClientHeader is the caller's own request id, recorded, never set. ClientHeader = "X-Request-ID" // Prefix starts every id this package mints. Prefix = "tyai_" // ContextKey is the context key the id is stored under. It is a plain // string because plugins and hooks have always read it that way. ContextKey = "request_id" // ClientContextKey holds the caller's sanitised X-Request-ID. ClientContextKey = "client_request_id" // MaxClientLen bounds a recorded client request id. MaxClientLen = 128 )
Variables ¶
This section is empty.
Functions ¶
func ClientFromContext ¶
ClientFromContext returns the caller's request id in ctx, "" when none.
func FromContext ¶
FromContext returns the request id in ctx, "" when there is none.
func SanitizeClient ¶
SanitizeClient keeps a caller-supplied id to MaxClientLen characters of letters, digits and - _ . : / so it cannot write into a log line or event.
Types ¶
This section is empty.