correlation

package
v0.9.64 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestIDHeader = "X-Request-ID"
	B3TraceIDHeader = "X-B3-TraceId"
	TraceIDHeader   = "X-CSGLite-Trace-ID"
	ThreadIDHeader  = "X-CSGLite-Thread-ID"
)

Variables

This section is empty.

Functions

func ApplyRequestHeaders

func ApplyRequestHeaders(req *http.Request)

ApplyRequestHeaders propagates correlation only to trusted downstreams.

func ApplyResponseHeaders

func ApplyResponseHeaders(headers http.Header, values Values)

func NormalizeB3TraceID

func NormalizeB3TraceID(value string) string

NormalizeB3TraceID enforces the B3 requirement of 64- or 128-bit non-zero lowercase hexadecimal trace identifiers.

func NormalizeID

func NormalizeID(value string) string

NormalizeID accepts printable correlation IDs without whitespace or header delimiters. This keeps logs single-line and prevents malformed propagation.

func WithContext

func WithContext(ctx context.Context, values Values) context.Context

Types

type Values

type Values struct {
	RequestID string
	TraceID   string
	B3TraceID string
	ThreadID  string
}

Values contains correlation identifiers for one inbound API request. TraceID is the logical csghub-lite trace, while B3TraceID identifies the distributed request path through trusted downstream inference services.

func FromContext

func FromContext(ctx context.Context) (Values, bool)

func FromHeaders

func FromHeaders(headers http.Header) Values

FromHeaders accepts valid caller identifiers and fills every missing value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL