replayimpl

package
v0.0.0-...-2ae3236 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	//nolint:revive // TODO(AML) Fix revive linter
	ErrHeaderWrite = fmt.Errorf("capture file header could not be fully written to buffer")
)

Functions

func GetUcredsForPid

func GetUcredsForPid(pid int32) []byte

GetUcredsForPid returns the replay ucreds for the specified pid

func NewTrafficCapture

func NewTrafficCapture(deps Requires) replay.Component

func OpenFile

func OpenFile(fs afero.Fs, l string, defaultLocation string) (afero.File, string, error)

OpenFile checks that location is acceptable for a capture and creates a new file using given fs implementation.

func WriteHeader

func WriteHeader(w io.Writer) error

WriteHeader writes the datadog header to the Writer argument to conform to the .dog file format.

Types

type Requires

type Requires struct {
	Lc     compdef.Lifecycle
	Config configComponent.Component
	Tagger tagger.Component
}

type TrafficCaptureReader

type TrafficCaptureReader struct {
	Contents []byte

	Version int
	Traffic chan *pb.UnixDogstatsdMsg
	Done    chan struct{}

	sync.Mutex
	// contains filtered or unexported fields
}

TrafficCaptureReader allows reading back a traffic capture and its contents

func NewTrafficCaptureReader

func NewTrafficCaptureReader(path string, depth int, mmap bool) (*TrafficCaptureReader, error)

NewTrafficCaptureReader creates a TrafficCaptureReader instance

func (*TrafficCaptureReader) Close

func (tc *TrafficCaptureReader) Close() error

Close cleans up any resources used by the TrafficCaptureReader, should not normally be called directly.

func (*TrafficCaptureReader) Read

func (tc *TrafficCaptureReader) Read(ready chan struct{})

Read reads the contents of the traffic capture and writes each packet to a channel

func (*TrafficCaptureReader) ReadNext

func (tc *TrafficCaptureReader) ReadNext() (*pb.UnixDogstatsdMsg, error)

ReadNext reads the next packet found in the file and returns the protobuf representation and an error if any.

func (*TrafficCaptureReader) ReadState

func (tc *TrafficCaptureReader) ReadState() (map[int32]string, map[string]*pb.Entity, error)

ReadState reads the tagger state from the end of the capture file. The internal offset of the reader is not modified by this operation.

func (*TrafficCaptureReader) Seek

func (tc *TrafficCaptureReader) Seek(offset uint32)

Seek sets the reader to the specified offset. Please note, the specified offset is relative to the first datagram, not the absolute position in the file, that would include the header. Thus, an offset of 0 would be the first datagram. Use with caution, a bad offset will completely mess up a replay.

func (*TrafficCaptureReader) Shutdown

func (tc *TrafficCaptureReader) Shutdown() error

Shutdown triggers the fuse if there's an ongoing read routine, and closes the reader.

type TrafficCaptureWriter

type TrafficCaptureWriter struct {
	Traffic chan *replay.CaptureBuffer

	// Synchronizes access to ongoing, accepting and closing of Traffic
	sync.RWMutex
	// contains filtered or unexported fields
}

TrafficCaptureWriter allows writing dogstatsd traffic to a file.

func NewTrafficCaptureWriter

func NewTrafficCaptureWriter(depth int, tagger tagger.Component) *TrafficCaptureWriter

NewTrafficCaptureWriter creates a TrafficCaptureWriter instance.

func (*TrafficCaptureWriter) Capture

func (tc *TrafficCaptureWriter) Capture(target io.WriteCloser, d time.Duration, compressed bool)

Capture start the traffic capture and writes the packets to file at the specified location and for the specified duration.

func (*TrafficCaptureWriter) Enqueue

func (tc *TrafficCaptureWriter) Enqueue(msg *replay.CaptureBuffer) bool

Enqueue enqueues a capture buffer so it's written to file.

func (*TrafficCaptureWriter) IsOngoing

func (tc *TrafficCaptureWriter) IsOngoing() bool

IsOngoing returns whether a capture is ongoing for this TrafficCaptureWriter instance.

func (*TrafficCaptureWriter) RegisterOOBPoolManager

func (tc *TrafficCaptureWriter) RegisterOOBPoolManager(p *packets.PoolManager[[]byte]) error

RegisterOOBPoolManager registers the OOB shared pool manager with the TrafficCaptureWriter.

func (*TrafficCaptureWriter) RegisterSharedPoolManager

func (tc *TrafficCaptureWriter) RegisterSharedPoolManager(p *packets.PoolManager[packets.Packet]) error

RegisterSharedPoolManager registers the shared pool manager with the TrafficCaptureWriter.

func (*TrafficCaptureWriter) StopCapture

func (tc *TrafficCaptureWriter) StopCapture()

StopCapture stops the ongoing capture if in process.

func (*TrafficCaptureWriter) Write

func (tc *TrafficCaptureWriter) Write(p []byte) (int, error)

Write writes the byte slice argument to file.

Jump to

Keyboard shortcuts

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