-
Notifications
You must be signed in to change notification settings - Fork 488
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
Improve duration formatting #647
Improve duration formatting #647
Conversation
782ccf3
to
90b6cc7
Compare
Thanks for the PR. I am not sold on multi-unit form being the best representation. E.g. it's much clearer to show 1.5s than 1s 500 ms, but that's the easy one (and also sub-second values are normal decimals that require no tricks, unlike h:m:s that use different multiples). I think two nearby units could be ok, like 4d 2h, but not 4d 2m (irrelevant precision). More than two units seems like overkill always. |
They sound like good points. I'll change the number of units displayed to 2 so I agree with you on using decimal points for seconds, milliseconds and microseconds as they are decimal based, but I think splitting the units is clearer on minutes, hours and days due to the odd numbers of units. Would the following displays be better?
|
all these examples look good to me. |
@yurishkuro Just updated the PR to match those examples |
@@ -0,0 +1,71 @@ | |||
// Copyright (c) 2017 Uber Technologies, Inc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Copyright (c) 2017 Uber Technologies, Inc. | |
// Copyright (c) 2020 The Jaeger Authors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍
trying to fix code coverage run #649 |
Codecov Report
@@ Coverage Diff @@
## master #647 +/- ##
=======================================
Coverage 93.74% 93.75%
=======================================
Files 227 227
Lines 5902 5906 +4
Branches 1483 1484 +1
=======================================
+ Hits 5533 5537 +4
Misses 328 328
Partials 41 41
Continue to review full report at Codecov.
|
// it('rounds the number of microseconds', () => { | ||
// const input = 256 * ONE_MILLISECOND + 0.7; | ||
// expect(formatDuration(input)).toBe('256ms 1μs'); | ||
// }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these look like they should be deleted?
f3dbf2b
to
b015843
Compare
Expands the number of units that the formatDuration function displays. Previously the function only used milliseconds and seconds to display durations, now it will support all units up to days. This is to make it easier to read very long durations in the UI that would have previously only been displayed in seconds. As a side effect of this change, there are a few changes to the way existing durations are displayed: * 0ms -> 0μs * 0.15ms -> 150μs * 1.7s -> 1s 700ms Resolves jaegertracing#319 Signed-off-by: James Ferguson <jamesferguson497@gmail.com>
The inputUnit parameter was not used anywhere and significantly complicated the implementation of the formatDuration function. Now, all inputs are assumed to be in microseconds which is consistent with a few other methods in the date.tsx file. Signed-off-by: James Ferguson <jamesferguson497@gmail.com>
Reduces the number of units displayed by the dateFormat function to a maximum of 2. So "2d 5h 20m" will now be "2d 5h". Signed-off-by: James Ferguson <jamesferguson497@gmail.com>
This change will display durations less than a minute using decimals as 1.3s is easier to comprehend than 1s 300ms as it was being displayed before. Durations larger than a minute will still use multiple units. Eg. 5m 27s Signed-off-by: James Ferguson <jamesferguson497@gmail.com>
Signed-off-by: James Ferguson <jamesferguson497@gmail.com>
b015843
to
2f0f24c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
* Add more units to duration formatting Expands the number of units that the formatDuration function displays. Previously the function only used milliseconds and seconds to display durations, now it will support all units up to days. This is to make it easier to read very long durations in the UI that would have previously only been displayed in seconds. As a side effect of this change, there are a few changes to the way existing durations are displayed: * 0ms -> 0μs * 1.5μs * 1.5ms * 1.5s * 1m 30s * 1h 30m * 1d 12h Resolves jaegertracing#319 Signed-off-by: James Ferguson <jamesferguson497@gmail.com> * Remove inputUnit parameter of formatDuration The inputUnit parameter was not used anywhere and significantly complicated the implementation of the formatDuration function. Now, all inputs are assumed to be in microseconds which is consistent with a few other methods in the date.tsx file. Signed-off-by: James Ferguson <jamesferguson497@gmail.com> * Reduce date format units to 2 Reduces the number of units displayed by the dateFormat function to a maximum of 2. So "2d 5h 20m" will now be "2d 5h". Signed-off-by: James Ferguson <jamesferguson497@gmail.com> * Use decimals when formating μs, ms and s durations This change will display durations less than a minute using decimals as 1.3s is easier to comprehend than 1s 300ms as it was being displayed before. Durations larger than a minute will still use multiple units. Eg. 5m 27s Signed-off-by: James Ferguson <jamesferguson497@gmail.com> * Fix date.test.js licence Signed-off-by: James Ferguson <jamesferguson497@gmail.com> Signed-off-by: vvvprabhakar <vvvprabhakar@gmail.com>
* Add more units to duration formatting Expands the number of units that the formatDuration function displays. Previously the function only used milliseconds and seconds to display durations, now it will support all units up to days. This is to make it easier to read very long durations in the UI that would have previously only been displayed in seconds. As a side effect of this change, there are a few changes to the way existing durations are displayed: * 0ms -> 0μs * 1.5μs * 1.5ms * 1.5s * 1m 30s * 1h 30m * 1d 12h Resolves jaegertracing#319 Signed-off-by: James Ferguson <jamesferguson497@gmail.com> * Remove inputUnit parameter of formatDuration The inputUnit parameter was not used anywhere and significantly complicated the implementation of the formatDuration function. Now, all inputs are assumed to be in microseconds which is consistent with a few other methods in the date.tsx file. Signed-off-by: James Ferguson <jamesferguson497@gmail.com> * Reduce date format units to 2 Reduces the number of units displayed by the dateFormat function to a maximum of 2. So "2d 5h 20m" will now be "2d 5h". Signed-off-by: James Ferguson <jamesferguson497@gmail.com> * Use decimals when formating μs, ms and s durations This change will display durations less than a minute using decimals as 1.3s is easier to comprehend than 1s 300ms as it was being displayed before. Durations larger than a minute will still use multiple units. Eg. 5m 27s Signed-off-by: James Ferguson <jamesferguson497@gmail.com> * Fix date.test.js licence Signed-off-by: James Ferguson <jamesferguson497@gmail.com> Signed-off-by: vvvprabhakar <vvvprabhakar@gmail.com>
* Add more units to duration formatting Expands the number of units that the formatDuration function displays. Previously the function only used milliseconds and seconds to display durations, now it will support all units up to days. This is to make it easier to read very long durations in the UI that would have previously only been displayed in seconds. As a side effect of this change, there are a few changes to the way existing durations are displayed: * 0ms -> 0μs * 1.5μs * 1.5ms * 1.5s * 1m 30s * 1h 30m * 1d 12h Resolves jaegertracing#319 Signed-off-by: James Ferguson <jamesferguson497@gmail.com> * Remove inputUnit parameter of formatDuration The inputUnit parameter was not used anywhere and significantly complicated the implementation of the formatDuration function. Now, all inputs are assumed to be in microseconds which is consistent with a few other methods in the date.tsx file. Signed-off-by: James Ferguson <jamesferguson497@gmail.com> * Reduce date format units to 2 Reduces the number of units displayed by the dateFormat function to a maximum of 2. So "2d 5h 20m" will now be "2d 5h". Signed-off-by: James Ferguson <jamesferguson497@gmail.com> * Use decimals when formating μs, ms and s durations This change will display durations less than a minute using decimals as 1.3s is easier to comprehend than 1s 300ms as it was being displayed before. Durations larger than a minute will still use multiple units. Eg. 5m 27s Signed-off-by: James Ferguson <jamesferguson497@gmail.com> * Fix date.test.js licence Signed-off-by: James Ferguson <jamesferguson497@gmail.com> Signed-off-by: vvvprabhakar <vvvprabhakar@gmail.com>
Which problem is this PR solving?
Resolves #319
Short description of the changes
Improves the duration formatting in the UI so that larger durations are easier to read. I've listed some examples below comparing the old and new formatting:
Each of these behaviours are open for discussion, I just tried to pick something that looked sensible.
In addition, this PR also removes the
inputUnit
parameter of theformatDuration
function. I did this because the parameter would significantly complicate the implementation of the function and it isn't used anywhere I could find in the code base. The duration is always assumed to be given in microseconds which is consistent with the behaviour of other functions in the file. If a duration of a different unit is ever used, then it is probably best to create a function that will convert it to microseconds before passing it to theformatDuration
function.