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

Tiny Duration Fix #3119

Merged
merged 2 commits into from
Jul 2, 2024
Merged

Tiny Duration Fix #3119

merged 2 commits into from
Jul 2, 2024

Conversation

jameskerr
Copy link
Member

@jameskerr jameskerr commented Jul 1, 2024

Fixes #3101

With this fix:

If the duration is less than 1 second, it will display "xxxmilliseconds"
If it is less than 1 millisecond, it will display "less than one millisecond"

CleanShot 2024-07-01 at 11 34 24@2x

@@ -14,10 +15,10 @@ export class ZeekEvent implements SecurityEventInterface {

getEndTime() {
if (this.r.get("_path").toString() !== "conn") return null
const dur = this.r.get<zed.Duration>("duration").asSeconds()
if (!dur) return
const dur = this.r.get<zed.Duration>("duration").asMs()
Copy link
Member Author

Choose a reason for hiding this comment

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

Use milliseconds here instead of seconds, to get the most precision we can.

@@ -14,7 +14,11 @@ export default function formatDir(start, end) {
parts.push(formatPart(obj[unit], unit))
}
if (allZero) {
parts.push(formatPart((end.getTime() - start.getTime()) / 1000, "seconds"))
if (end.getTime() === start.getTime()) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Check if the two dates are the same to determine if the duration is less than 1ms.

@jameskerr jameskerr requested a review from philrz July 1, 2024 18:37
Copy link
Contributor

@philrz philrz left a comment

Choose a reason for hiding this comment

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

The fix seems effective. I saw one of the tests was broken so I pushed a commit to fix it.

@jameskerr
Copy link
Member Author

Thanks Phil!

@jameskerr jameskerr merged commit 804fe3f into main Jul 2, 2024
4 checks passed
@jameskerr jameskerr deleted the tiny-duration branch July 2, 2024 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tiny duration shown as "Not available" in correlations view
2 participants