Documentation ¶
Index ¶
- Variables
- func GetUcredsForPid(pid int32) []byte
- func NewTrafficCapture(deps Requires) replay.Component
- func OpenFile(fs afero.Fs, l string, defaultLocation string) (afero.File, string, error)
- func WriteHeader(w io.Writer) error
- type Requires
- type TrafficCaptureReader
- func (tc *TrafficCaptureReader) Close() error
- func (tc *TrafficCaptureReader) Read(ready chan struct{})
- func (tc *TrafficCaptureReader) ReadNext() (*pb.UnixDogstatsdMsg, error)
- func (tc *TrafficCaptureReader) ReadState() (map[int32]string, map[string]*pb.Entity, error)
- func (tc *TrafficCaptureReader) Seek(offset uint32)
- func (tc *TrafficCaptureReader) Shutdown() error
- type TrafficCaptureWriter
- func (tc *TrafficCaptureWriter) Capture(target io.WriteCloser, d time.Duration, compressed bool)
- func (tc *TrafficCaptureWriter) Enqueue(msg *replay.CaptureBuffer) bool
- func (tc *TrafficCaptureWriter) IsOngoing() bool
- func (tc *TrafficCaptureWriter) RegisterOOBPoolManager(p *packets.PoolManager[[]byte]) error
- func (tc *TrafficCaptureWriter) RegisterSharedPoolManager(p *packets.PoolManager[packets.Packet]) error
- func (tc *TrafficCaptureWriter) StopCapture()
- func (tc *TrafficCaptureWriter) Write(p []byte) (int, error)
Constants ¶
This section is empty.
Variables ¶
var ( //nolint:revive // TODO(AML) Fix revive linter ErrHeaderWrite = fmt.Errorf("capture file header could not be fully written to buffer") )
Functions ¶
func GetUcredsForPid ¶
GetUcredsForPid returns the replay ucreds for the specified pid
func NewTrafficCapture ¶
func OpenFile ¶
OpenFile checks that location is acceptable for a capture and creates a new file using given fs implementation.
func WriteHeader ¶
WriteHeader writes the datadog header to the Writer argument to conform to the .dog file format.
Types ¶
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 ¶
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.