Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maint: Log when request/response timestamp is not set & set to time.Now #179

Merged
merged 2 commits into from
Sep 14, 2023

Conversation

MikeGoldsmith
Copy link
Contributor

Which problem is this PR solving?

The agent occasionally pairs a http request/response pair where the response timestamp is zero. This results in a negative huge value when trying to calculate the event duration.

This PR moves the event duration calculation from the http reader to event processing, detects if either the request or response timestamp is zero and sets to now &

Short description of the changes

  • Move event duration calculation from http reader to event processing
  • Log and add debug event fields if either request or response timestamps are zero
  • Set zero timestamps to now to prevent negative durations

How to verify that this has the expected result

While negative durations are infrequent (eg 3 in 24 hours), we have a kibble board to track which should show no further negative durations.

image

@MikeGoldsmith MikeGoldsmith added the type: maintenance The necessary chores to keep the dust off. label Sep 14, 2023
@MikeGoldsmith MikeGoldsmith self-assigned this Sep 14, 2023
@MikeGoldsmith MikeGoldsmith requested a review from a team September 14, 2023 12:55
Copy link
Contributor

@JamieDanielson JamieDanielson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - one suggestion for an additional check on a negative duration and setting to 0.

event.ResponseTimestamp = time.Now()
}
eventDuration := event.ResponseTimestamp.Sub(event.RequestTimestamp)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add an extra check in here for other goofiness like request timestamp being greater than response timestamp? Something like if eventDuration < 0 { eventDuration = 0 }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need it - whenever we've seen a negative duration it's because the response timestamp is zero (ie 0001-01-01T00:00:00Z) which means the duration is calculated badly. I think because of the TCP requirement of request then response, as long as we have both sides, we can calculate the duration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: maintenance The necessary chores to keep the dust off.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants