tracecapture

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package tracecapture provides bounded, side-effect-free trace capture leaves shared by Generic API and LLM request recorders.

Index

Constants

View Source
const (
	ReasonTraceHeadersOnly  = "trace_headers_only"
	ReasonContentEncoded    = "content_encoded"
	ReasonMultipart         = "multipart"
	ReasonBinaryContentType = "binary_content_type"
	ReasonBinaryDetected    = "binary_detected"
	ReasonWebSocket         = "websocket"
	ReasonCaptureReadFailed = "capture_read_failed"
)
View Source
const (
	RedactedValue       = "***"
	MaxHeaderFields     = 64
	MaxHeaderValues     = 8
	MaxHeaderNameBytes  = 256
	MaxHeaderValueBytes = 1024
	MaxHeadersBytes     = 32 * 1024
)
View Source
const DefaultBodyWindowBytes = 64 * 1024

Variables

This section is empty.

Functions

func PolicyFromToken

func PolicyFromToken(enabled bool, rawMode string, maxBodyBytes int) (apiattempt.APITracePolicy, bool)

PolicyFromToken applies the shared runtime semantics: disabled is off, legacy empty is full, headers is headers, and unknown modes fail open to full capture while reporting unknown=true to the caller.

func RedactHeaders

func RedactHeaders(source http.Header, dynamicSensitiveNames ...string) (http.Header, bool)

RedactHeaders returns a deterministic, explicitly bounded clone suitable for both ordinary headers and trailers. Dynamic names cover custom upstream auth.

Types

type BodyCaptureDecision

type BodyCaptureDecision struct {
	Capture bool
	Reason  string
}

func DecideBody

func DecideBody(protocol, contentType, contentEncoding string, textBody bool) BodyCaptureDecision

DecideBody returns whether a completed bounded body window is safe to persist. It never decodes content encodings or serializes opaque bytes.

type BodyWindow

type BodyWindow struct {
	// contains filtered or unexported fields
}

BodyWindow is a fixed-capacity streaming tail. Write always acknowledges the original byte count, so capture cannot change the surrounding I/O contract.

func NewBodyWindow

func NewBodyWindow(limit int) *BodyWindow

func (*BodyWindow) Bytes

func (window *BodyWindow) Bytes() []byte

func (*BodyWindow) Capture

func (window *BodyWindow) Capture(decision BodyCaptureDecision) apiattempt.APIBodyCapture

func (*BodyWindow) Len

func (window *BodyWindow) Len() int

func (*BodyWindow) Limit

func (window *BodyWindow) Limit() int

func (*BodyWindow) MarkReadFailed

func (window *BodyWindow) MarkReadFailed()

func (*BodyWindow) Reset

func (window *BodyWindow) Reset()

func (*BodyWindow) String

func (window *BodyWindow) String() string

func (*BodyWindow) Text

func (window *BodyWindow) Text() bool

func (*BodyWindow) TotalBytes

func (window *BodyWindow) TotalBytes() int64

func (*BodyWindow) TotalSeen

func (window *BodyWindow) TotalSeen() int64

func (*BodyWindow) Truncated

func (window *BodyWindow) Truncated() bool

func (*BodyWindow) Write

func (window *BodyWindow) Write(value []byte) (int, error)

func (*BodyWindow) WriteString

func (window *BodyWindow) WriteString(value string) (int, error)

Jump to

Keyboard shortcuts

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