Skip to content

Commit

Permalink
chore: log when we've got an event where time's gone wobbly (#137)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?

- In service to debugging #114 

## Short description of the changes

- added log output to assist debugging what makes an HTTP event appear
to have been responded to before the request was sent 😁
  • Loading branch information
robbkidd authored Aug 30, 2023
1 parent bcc99a3 commit 770937b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion assemblers/http_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,22 @@ func (h *httpReader) run(wg *sync.WaitGroup) {
}

func (h *httpReader) processEvent(ident string, entry *entry) {
eventDuration := entry.responseTimestamp.Sub(entry.requestTimestamp)
if eventDuration < 0 { // the response came in before the request? wat?
// logging the weirdness for now so we can debug in environments with production loads
log.Debug().
Str("ident", ident).
Int64("duration_ns", int64(eventDuration)).
Int64("duration_ms", eventDuration.Milliseconds()).
Msg("Time has gotten weird for this event.")
}

h.parent.events <- HttpEvent{
RequestId: ident,
Request: entry.request,
Response: entry.response,
Timestamp: entry.requestTimestamp,
Duration: entry.responseTimestamp.Sub(entry.requestTimestamp),
Duration: eventDuration,
SrcIp: h.srcIp,
DstIp: h.dstIp,
}
Expand Down

0 comments on commit 770937b

Please sign in to comment.