()
| 373 | } |
| 374 | |
| 375 | func (p *Parser) Finish() error { |
| 376 | if sendReflector { |
| 377 | DefaultPublisher.inflight.Add(1) |
| 378 | defer DefaultPublisher.inflight.Done() |
| 379 | } |
| 380 | |
| 381 | p.wg.Wait() |
| 382 | if err := errors.Join(<-p.errs, <-p.errs); err != nil { |
| 383 | return err |
| 384 | } |
| 385 | |
| 386 | var logidx uint64 |
| 387 | var loglines []string |
| 388 | if journal.Enabled { |
| 389 | logidx, loglines = p.global.Journal.CopyFrom(p.journalIdx) |
| 390 | } |
| 391 | |
| 392 | entry := &extendedHarEntry{ |
| 393 | Entry: &har.Entry{ |
| 394 | ID: p.event.Get("event_id"), |
| 395 | StartedDateTime: p.begin.UTC(), |
| 396 | Time: time.Since(p.begin).Milliseconds(), |
| 397 | Request: p.request, |
| 398 | Response: p.response, |
| 399 | Timings: &p.timings, |
| 400 | }, |
| 401 | WebSocketMessages: p.websocketMessages, |
| 402 | } |
| 403 | |
| 404 | for k, v := range stats.Load() { |
| 405 | p.event.Set(k, v) |
| 406 | } |
| 407 | |
| 408 | tags := p.global.Config.GetEventTemplate() |
| 409 | tags.CopyFrom(p.event) |
| 410 | tags.Set("event_id", p.event.Get("event_id")) |
| 411 | tags.Set("time", p.event.Get("time")) |
| 412 | |
| 413 | // HAR v1.2 doesn't support trailers so for now we just set the counts as a |
| 414 | // way to indicate to the user that there were trailers. |
| 415 | if p.requestTrailer != nil { |
| 416 | tags.Set("request_trailer_count", fmt.Sprintf("%d", len(p.requestTrailer))) |
| 417 | } |
| 418 | if p.responseTrailer != nil { |
| 419 | tags.Set("response_trailer_count", fmt.Sprintf("%d", len(p.responseTrailer))) |
| 420 | } |
| 421 | |
| 422 | { |
| 423 | begin := time.Now() |
| 424 | match, err := p.global.Config.GetMatchingFilter(tags.Map(), entry.Entry) |
| 425 | slog.Debug("evaluated filters", "eventID", p.event.Get("event_id"), "match", match, "err", err, "took", time.Since(begin).Round(time.Nanosecond)) |
| 426 | switch { |
| 427 | case err != nil: |
| 428 | fallthrough // fallthrough to ActionInclude if filter eval fails |
| 429 | case match == nil: |
| 430 | break |
| 431 | case match.Action == filter.ActionInclude: |
| 432 | break |
no test coverage detected