netdebug

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package netdebug connects optional transport diagnostics to the SDK log queue without adding HTTP dependencies to plugins that do not use HTTP

Index

Constants

View Source
const BodyLimit = 64 << 10
View Source
const HeaderCount = 128
View Source
const HeaderLimit = 8 << 10

Variables

This section is empty.

Functions

func Clear

func Clear(owner any)

Remove the diagnostic sink belonging to an owner

func Configure

func Configure(owner any, enabled bool, report func(Event))

Configure the diagnostic sink for a connection owner

func Endpoint

func Endpoint(raw string) string

Endpoint discards userinfo, fragments and every query value

func HeaderRedactor

func HeaderRedactor(redact func(string) string, headers ...*Headers) func(string) string

HeaderRedactor also removes header credentials echoed in another field/body

func IO

func IO(address net.Addr, operation string, size int)

Report socket I/O metadata without including payload bytes

func SensitiveHeader

func SensitiveHeader(name string) bool

Identify credential-bearing and otherwise sensitive headers

Types

type Body

type Body struct {
	Text        string `json:"text"`
	Encoding    string `json:"encoding"`
	ContentType string `json:"content_type"`
	Bytes       uint64 `json:"bytes"`
	Complete    bool   `json:"complete"`
	Truncated   bool   `json:"truncated"`
}

func (*Body) Sanitize

func (b *Body) Sanitize(redact func(string) string)

Sanitize applies known credential redaction to raw bytes before binary encoding, and masks credential fields in complete JSON and form bodies

type Capture

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

Capture only retains bytes that the caller actually reads. Oversized bodies are omitted entirely, so a truncated credential cannot escape sanitization

func NewCapture

func NewCapture(contentType string, expected int64, empty bool) *Capture

Create a bounded request or response body capture

func (*Capture) Done

func (c *Capture) Done(eof bool)

Record whether the captured body reached its end

func (*Capture) Snapshot

func (c *Capture) Snapshot() Body

Return a snapshot of the captured body

func (*Capture) Write

func (c *Capture) Write(data []byte)

Append bytes while respecting the diagnostic capture limit

type Details

type Details struct {
	RequestID       string   `json:"request_id"`
	Request         Body     `json:"request"`
	Response        Body     `json:"response"`
	RequestHeaders  *Headers `json:"request_headers,omitempty"`
	ResponseHeaders *Headers `json:"response_headers,omitempty"`
}

type Event

type Event struct {
	Message string
	Failed  bool
	Details *Details
}
type Header struct {
	Name   string   `json:"name"`
	Values []string `json:"values"`
}

type HeaderCapture

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

HeaderCapture keeps a bounded snapshot, never retaining a partial field value Wire trace callbacks replace the request-map fallback without mutating traffic

func NewHeaders

func NewHeaders(values map[string][]string) *HeaderCapture

Create a bounded capture of HTTP headers

func (*HeaderCapture) Snapshot

func (c *HeaderCapture) Snapshot() *Headers

Return a snapshot of the captured headers

func (*HeaderCapture) Written

func (c *HeaderCapture) Written(name string, values []string)

Record the values actually written for a header

func (*HeaderCapture) WroteRequest

func (c *HeaderCapture) WroteRequest()

Advance the capture to the next request after transmission

type Headers

type Headers struct {
	Entries   []Header `json:"entries"`
	Truncated bool     `json:"truncated"`
	// contains filtered or unexported fields
}

func (*Headers) Sanitize

func (h *Headers) Sanitize(redact func(string) string)

Apply redaction to stored header metadata

type Trace

type Trace struct {
	Request, Response               *Capture
	RequestHeaders, ResponseHeaders *HeaderCapture
	// contains filtered or unexported fields
}

func Start

func Start(method string, endpoint *url.URL) *Trace

Start a bounded HTTP diagnostic trace

func (*Trace) Finish

func (t *Trace) Finish(status int, err error)

Publish the completed trace with status or failure details

Jump to

Keyboard shortcuts

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