MCPcopy Create free account
hub / github.com/rabbitstack/fibratus / WriteCapture

Method WriteCapture

internal/bootstrap/bootstrap.go:275–306  ·  view source on GitHub ↗

WriteCapture writes the event stream to the capture file.

(args []string)

Source from the content-addressed store, hash-verified

273
274// WriteCapture writes the event stream to the capture file.
275func (f *App) WriteCapture(args []string) error {
276 if f.evs == nil {
277 panic("event source is nil")
278 }
279
280 if !f.isSingleInstance() {
281 return ErrAlreadyRunning
282 }
283
284 fltr, err := filter.NewFromCLI(args, f.config)
285 if err != nil {
286 return err
287 }
288 if fltr != nil {
289 f.evs.SetFilter(fltr)
290 }
291 err = f.evs.Open(f.config)
292 if err != nil {
293 return err
294 }
295 f.writer, err = cap.NewWriter(f.config.CapFile, f.psnap, f.hsnap)
296 if err != nil {
297 return err
298 }
299 errsChan := f.writer.Write(f.evs.Events(), f.evs.Errors())
300 go func() {
301 for err := range errsChan {
302 log.Warnf("fail to write event to capture: %v", err)
303 }
304 }()
305 return api.StartServer(f.config)
306}
307
308// ReadCapture reconstructs the event stream from the capture file.
309func (f *App) ReadCapture(ctx context.Context, args []string) error {

Callers 1

captureFunction · 0.95

Calls 9

isSingleInstanceMethod · 0.95
NewFromCLIFunction · 0.92
NewWriterFunction · 0.92
StartServerFunction · 0.92
SetFilterMethod · 0.65
OpenMethod · 0.65
WriteMethod · 0.65
EventsMethod · 0.65
ErrorsMethod · 0.65

Tested by

no test coverage detected