recorder

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 1 Imported by: 2 modules, 26 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 recorder defines the Recorder interface for capturing traffic data — hex dumps, HTTP body recording, and directional traffic logging.

Index

Constants

View Source
const (
	RecorderServiceClientAddress          = "recorder.service.client.address"
	RecorderServiceRouterDialAddress      = "recorder.service.router.dial.address"
	RecorderServiceRouterDialAddressError = "recorder.service.router.dial.address.error"
)

Recorder event key constants used as metadata keys in record operations.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Direction indicates the traffic direction (true = client-to-server).
	Direction bool
	// TimestampFormat is the Go time format string for timestamps.
	TimestampFormat string
	// Hexdump enables hexadecimal dump output.
	Hexdump bool
	// HTTPBody enables HTTP request/response body capture.
	HTTPBody bool
	// MaxBodySize is the maximum body size to record.
	MaxBodySize int
}

Options configures a Recorder's behavior.

type RecordOption

type RecordOption func(opts *RecordOptions)

RecordOption is a functional option for configuring RecordOptions.

func MetadataRecordOption

func MetadataRecordOption(md any) RecordOption

MetadataRecordOption sets the metadata for the record operation.

type RecordOptions

type RecordOptions struct {
	// Metadata is contextual data attached to the record operation.
	Metadata any
}

RecordOptions holds runtime parameters for a Record call.

type Recorder

type Recorder interface {
	// Record processes a buffer of traffic data.
	Record(ctx context.Context, b []byte, opts ...RecordOption) error
}

Recorder captures traffic data. Implementations may write hex dumps, log HTTP request/response bodies, or forward data to external collectors.

type RecorderObject

type RecorderObject struct {
	// Recorder is the recorder implementation.
	Recorder Recorder
	// Record is the recorder's registered name.
	Record string
	// Options configures what data is recorded.
	Options *Options
	// Metadata is arbitrary metadata attached to the recorder,
	// forwarded to plugin recorders on every Record call.
	Metadata map[string]any
}

RecorderObject bundles a Recorder with its name and configuration. It is used in RouterOptions and Handler options to attach recording to specific points in the request path.

Jump to

Keyboard shortcuts

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