recorder

package
v0.28.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: 21 Imported by: ? 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

Index

Constants

View Source
const (
	RecorderServiceHandler       = "recorder.service.handler"
	RecorderServiceHandlerSerial = "recorder.service.handler.serial"
	RecorderServiceHandlerTunnel = "recorder.service.handler.tunnel"
)
View Source
const (
	PhaseInterim = "interim"
	PhaseFinal   = "final"
)
View Source
const MinPeriod = time.Second

Variables

View Source
var ErrSessionRecorderClosed = errors.New("session recorder is closed")

Functions

func FileRecorder

func FileRecorder(out io.WriteCloser, opts ...FileRecorderOption) recorder.Recorder

FileRecorder records data to file.

func HTTPRecorder

func HTTPRecorder(url string, opts ...HTTPRecorderOption) recorder.Recorder

HTTPRecorder records data to HTTP service.

func RedisListRecorder

func RedisListRecorder(addr string, opts ...RedisRecorderOption) recorder.Recorder

RedisListRecorder records data to a redis list.

func RedisSetRecorder

func RedisSetRecorder(addr string, opts ...RedisRecorderOption) recorder.Recorder

RedisSetRecorder records data to a redis set.

func RedisSortedSetRecorder

func RedisSortedSetRecorder(addr string, opts ...RedisRecorderOption) recorder.Recorder

RedisSortedSetRecorder records data to a redis sorted set.

func TCPRecorder

func TCPRecorder(addr string, opts ...TCPRecorderOption) recorder.Recorder

TCPRecorder records data to TCP service.

Types

type DNSRecorderObject added in v0.0.3

type DNSRecorderObject struct {
	ID       int    `json:"id"`
	Name     string `json:"name"`
	Class    string `json:"class"`
	Type     string `json:"type"`
	Question string `json:"question"`
	Answer   string `json:"answer"`
	Cached   bool   `json:"cached"`
}

DNSRecorderObject holds the recorded data of a DNS query and response.

type FileRecorderOption

type FileRecorderOption func(opts *fileRecorderOptions)

FileRecorderOption configures FileRecorder options.

func RecorderFileRecorderOption added in v0.0.3

func RecorderFileRecorderOption(recorder string) FileRecorderOption

RecorderFileRecorderOption sets the recorder name for metrics labeling.

func SepFileRecorderOption added in v0.0.3

func SepFileRecorderOption(sep string) FileRecorderOption

SepFileRecorderOption sets the record separator written after each record.

type HTTPRecorderObject added in v0.0.3

type HTTPRecorderObject struct {
	Host       string                     `json:"host"`
	Method     string                     `json:"method"`
	Proto      string                     `json:"proto"`
	Scheme     string                     `json:"scheme"`
	URI        string                     `json:"uri"`
	Cached     bool                       `json:"cached"`
	StatusCode int                        `json:"statusCode"`
	Request    HTTPRequestRecorderObject  `json:"request"`
	Response   HTTPResponseRecorderObject `json:"response"`

	// OriginalHost is the Host value before node HTTP rewrites were applied.
	OriginalHost string `json:"originalHost,omitempty"`
	// OriginalURI is the request URI before node URL/header rewrites were applied.
	OriginalURI string `json:"originalUri,omitempty"`
	// OriginalRequest holds the request header/body before node HTTP rewrites
	// were applied. Nil when no request-side rewrite is configured.
	OriginalRequest *HTTPRequestRecorderObject `json:"originalRequest,omitempty"`
	// OriginalResponse holds the response header/body before node HTTP rewrites
	// were applied. Nil when no response-side rewrite is configured. For a 101
	// Switching Protocols response, only headers are captured (there is no body).
	OriginalResponse *HTTPResponseRecorderObject `json:"originalResponse,omitempty"`
}

HTTPRecorderObject holds the recorded HTTP request and response data for a single HTTP transaction.

type HTTPRecorderOption

type HTTPRecorderOption func(opts *httpRecorderOptions)

HTTPRecorderOption configures HTTPRecorder options.

func HeaderHTTPRecorderOption added in v0.0.3

func HeaderHTTPRecorderOption(header http.Header) HTTPRecorderOption

HeaderHTTPRecorderOption sets additional HTTP headers sent with each record.

func RecorderHTTPRecorderOption added in v0.0.3

func RecorderHTTPRecorderOption(recorder string) HTTPRecorderOption

RecorderHTTPRecorderOption sets the recorder name for metrics labeling.

func TimeoutHTTPRecorderOption

func TimeoutHTTPRecorderOption(timeout time.Duration) HTTPRecorderOption

TimeoutHTTPRecorderOption sets the HTTP client timeout.

type HTTPRequestRecorderObject added in v0.0.3

type HTTPRequestRecorderObject struct {
	ContentLength int64       `json:"contentLength"`
	Header        http.Header `json:"header"`
	Body          []byte      `json:"body"`
}

HTTPRequestRecorderObject holds the recorded data of an HTTP request.

type HTTPResponseRecorderObject added in v0.0.3

type HTTPResponseRecorderObject struct {
	ContentLength int64       `json:"contentLength"`
	Header        http.Header `json:"header"`
	Body          []byte      `json:"body"`
}

HTTPResponseRecorderObject holds the recorded data of an HTTP response.

type HandlerRecorderObject added in v0.0.3

type HandlerRecorderObject struct {
	Node        string                   `json:"node,omitempty"`
	Service     string                   `json:"service"`
	Labels      map[string]string        `json:"labels,omitempty"`
	Network     string                   `json:"network"`
	RemoteAddr  string                   `json:"remote"`
	LocalAddr   string                   `json:"local"`
	ClientAddr  string                   `json:"client"`
	SrcAddr     string                   `json:"src"`
	DstAddr     string                   `json:"dst"`
	Host        string                   `json:"host"`
	Proto       string                   `json:"proto,omitempty"`
	ClientIP    string                   `json:"clientIP"`
	ClientID    string                   `json:"clientID,omitempty"`
	HTTP        *HTTPRecorderObject      `json:"http,omitempty"`
	Websocket   *WebsocketRecorderObject `json:"websocket,omitempty"`
	TLS         *TLSRecorderObject       `json:"tls,omitempty"`
	DNS         *DNSRecorderObject       `json:"dns,omitempty"`
	Redis       *RedisRecorderObject     `json:"redis,omitempty"`
	Route       string                   `json:"route,omitempty"`
	InputBytes  uint64                   `json:"inputBytes"`
	OutputBytes uint64                   `json:"outputBytes"`
	Redirect    string                   `json:"redirect,omitempty"`
	Err         string                   `json:"err,omitempty"`
	SID         string                   `json:"sid"`
	Duration    time.Duration            `json:"duration"`
	Time        time.Time                `json:"time"`
	RecordMode  string                   `json:"-"` // "" = full, "headers" = metadata only, "off" = no recording
}

HandlerRecorderObject bundles traffic metadata recorded at the handler level — addresses, protocols, transferred bytes, and optional sub-records for HTTP, WebSocket, TLS, and DNS traffic.

func (*HandlerRecorderObject) Record added in v0.0.3

Record serializes the HandlerRecorderObject as JSON and writes it to r. It returns nil if p or r is nil or if p.Time is the zero value.

type MetadataRecorder added in v0.28.1

type MetadataRecorder struct {
	recorder.Recorder
	Metadata any
}

MetadataRecorder wraps a Recorder and automatically appends metadata to every Record call.

func (*MetadataRecorder) Record added in v0.28.1

func (r *MetadataRecorder) Record(ctx context.Context, b []byte, opts ...recorder.RecordOption) error

type RedisRecorderObject added in v0.28.1

type RedisRecorderObject struct {
	Command string `json:"command"`
	Key     string `json:"key"`
}

RedisRecorderObject holds the recorded data of a sniffed Redis command.

type RedisRecorderOption

type RedisRecorderOption func(opts *redisRecorderOptions)

RedisRecorderOption configures Redis recorder options.

func DBRedisRecorderOption

func DBRedisRecorderOption(db int) RedisRecorderOption

DBRedisRecorderOption sets the Redis database number.

func KeyRedisRecorderOption

func KeyRedisRecorderOption(key string) RedisRecorderOption

KeyRedisRecorderOption sets the Redis key for storing records.

func PasswordRedisRecorderOption

func PasswordRedisRecorderOption(password string) RedisRecorderOption

PasswordRedisRecorderOption sets the Redis password for authentication.

func RecorderRedisRecorderOption added in v0.0.3

func RecorderRedisRecorderOption(recorder string) RedisRecorderOption

RecorderRedisRecorderOption sets the recorder name for metrics labeling.

func UsernameRedisRecorderOption added in v0.0.3

func UsernameRedisRecorderOption(username string) RedisRecorderOption

UsernameRedisRecorderOption sets the Redis username for authentication.

type Session added in v0.28.1

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

func (*Session) Finish added in v0.28.1

func (s *Session) Finish(ctx context.Context, final HandlerRecorderObject) error

func (*Session) Interim added in v0.28.1

func (s *Session) Interim(ctx context.Context, now time.Time) error

func (*Session) Start added in v0.28.1

func (s *Session) Start(base HandlerRecorderObject)

type SessionRecord added in v0.28.1

type SessionRecord struct {
	HandlerRecorderObject
	SessionID        string        `json:"sessionID"`
	RecordIndex      uint64        `json:"recordIndex"`
	Phase            string        `json:"phase"`
	InputBytesDelta  uint64        `json:"inputBytesDelta"`
	OutputBytesDelta uint64        `json:"outputBytesDelta"`
	DurationDelta    time.Duration `json:"durationDelta"`
}

type SessionRecorder added in v0.28.1

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

func NewSessionRecorder added in v0.28.1

func NewSessionRecorder(rec recorder.Recorder, opts SessionRecorderOptions) *SessionRecorder

func (*SessionRecorder) Close added in v0.28.1

func (r *SessionRecorder) Close() error

func (*SessionRecorder) Enabled added in v0.28.1

func (r *SessionRecorder) Enabled() bool

func (*SessionRecorder) NewSession added in v0.28.1

func (r *SessionRecorder) NewSession(ctx context.Context, counters stats.Stats) *Session

type SessionRecorderOptions added in v0.28.1

type SessionRecorderOptions struct {
	Period       time.Duration
	WriteTimeout time.Duration
}

type TCPRecorderOption

type TCPRecorderOption func(opts *tcpRecorderOptions)

TCPRecorderOption configures TCPRecorder options.

func LogTCPRecorderOption added in v0.0.3

func LogTCPRecorderOption(log logger.Logger) TCPRecorderOption

LogTCPRecorderOption sets the logger for the TCP recorder.

func RecorderTCPRecorderOption added in v0.0.3

func RecorderTCPRecorderOption(recorder string) TCPRecorderOption

RecorderTCPRecorderOption sets the recorder name for metrics labeling.

func TimeoutTCPRecorderOption

func TimeoutTCPRecorderOption(timeout time.Duration) TCPRecorderOption

TimeoutTCPRecorderOption sets the dial timeout for TCP connections.

type TLSRecorderObject added in v0.0.3

type TLSRecorderObject struct {
	ServerName        string `json:"serverName"`
	CipherSuite       string `json:"cipherSuite"`
	CompressionMethod uint8  `json:"compressionMethod"`
	Proto             string `json:"proto"`
	Version           string `json:"version"`
	ClientHello       string `json:"clientHello"`
	ServerHello       string `json:"serverHello"`
}

TLSRecorderObject holds the recorded data of a TLS handshake.

type WebsocketRecorderObject added in v0.0.3

type WebsocketRecorderObject struct {
	From    string `json:"from"`
	Fin     bool   `json:"fin"`
	Rsv1    bool   `json:"rsv1"`
	Rsv2    bool   `json:"rsv2"`
	Rsv3    bool   `json:"rsv3"`
	OpCode  int    `json:"opcode"`
	Masked  bool   `json:"masked"`
	MaskKey uint32 `json:"maskKey"`
	Length  int64  `json:"length"`
	Payload []byte `json:"payload"`
}

WebsocketRecorderObject holds the recorded data of a WebSocket frame.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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