Documentation
¶
Index ¶
- Constants
- Variables
- func FileRecorder(out io.WriteCloser, opts ...FileRecorderOption) recorder.Recorder
- func HTTPRecorder(url string, opts ...HTTPRecorderOption) recorder.Recorder
- func RedisListRecorder(addr string, opts ...RedisRecorderOption) recorder.Recorder
- func RedisSetRecorder(addr string, opts ...RedisRecorderOption) recorder.Recorder
- func RedisSortedSetRecorder(addr string, opts ...RedisRecorderOption) recorder.Recorder
- func TCPRecorder(addr string, opts ...TCPRecorderOption) recorder.Recorder
- type DNSRecorderObject
- type FileRecorderOption
- type HTTPRecorderObject
- type HTTPRecorderOption
- type HTTPRequestRecorderObject
- type HTTPResponseRecorderObject
- type HandlerRecorderObject
- type MetadataRecorder
- type RedisRecorderObject
- type RedisRecorderOption
- func DBRedisRecorderOption(db int) RedisRecorderOption
- func KeyRedisRecorderOption(key string) RedisRecorderOption
- func PasswordRedisRecorderOption(password string) RedisRecorderOption
- func RecorderRedisRecorderOption(recorder string) RedisRecorderOption
- func UsernameRedisRecorderOption(username string) RedisRecorderOption
- type Session
- type SessionRecord
- type SessionRecorder
- type SessionRecorderOptions
- type TCPRecorderOption
- type TLSRecorderObject
- type WebsocketRecorderObject
Constants ¶
const ( RecorderServiceHandler = "recorder.service.handler" RecorderServiceHandlerSerial = "recorder.service.handler.serial" RecorderServiceHandlerTunnel = "recorder.service.handler.tunnel" )
const ( PhaseInterim = "interim" PhaseFinal = "final" )
const MinPeriod = time.Second
Variables ¶
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.
type MetadataRecorder ¶ added in v0.28.1
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
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) 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
type SessionRecorderOptions ¶ added in v0.28.1
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.