-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Index Patterns Field Formatter] Added human readable precise formatter for duration #100540
Conversation
Pinging @elastic/uptime (Team:uptime) |
lgtm, reaching out to @wylieconlon to see if he has any thoughts on this before I give my 👍 |
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.
Hi @shahzad31 thanks for taking this on! The concept is pretty much exactly what users are requesting, and here's my feedback after testing it:
- Values less than 1 are bugged in this formatter, so just to take one example: with
nanoseconds
input,123
nanoseconds should either display as123 ns
,1.23 µs
, or0.000123 ms
- but currently displays0
. Same with negative values. I would expect that for values less than 1, the suffix would be chosen based on the number of decimal places that are displayed. So if I choose to display 6 decimal places I would see0.000123 ms
, but if I choose 0 decimal places it should be123 ns
. - Suffix should be required for this new formatter, same as the human readable
- The name "dynamic" is not very clear. I suggest renaming "human readable" -> approximate, and "dynamic" -> precise
- I suggest moving this new format option to be near the top of the list, not the bottom
- The value 0 should get a suffix too, as
0 ms
is still a unit. - Decimal places aren't affecting the value
0
, so if I have 2 decimals I want to see0.00 ms
- The suffixes you've chosen are inconsistent lengths and case, for example you have
d
,sec
, andYr
It would be great if the unit tests would test multiple cases per format setting, so that you can test the whole range of formats from negative, less than 1, very large, etc.
Pinging @elastic/kibana-app-services (Team:AppServices) |
i have addressed this
fixed as well
Fixed
Fixed
I have tried improving this
added few more tests |
@wylieconlon i fixed the bug, in case of human readable precise, show suffix isn't shown. Only the options to use short suffix is shown. Since that's still applicable. |
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.
LGTM! This is great, users will be happy to see this.
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.
changes lgtm and work well
@elasticmachine merge upstream |
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.
-
If I understood correctly then the old
Human readable
should becomeHuman-readable approximate
? But it looks like that when I check out this pr old fields that wereHuman readable
now useHuman-readable precise
, hence their format in apps change.
Is this behavior expected? I'd assume old fields should follow old formatting unless changed explicitly by a user? -
I noticed some inconsistencies between formatting when precise vs approximate are used:
For example, seeLooks like this was also the case before for other formatting options. Please ignorehours
vsHours
? Would it be difficult to improve?
- Also per the images above, looks like
precise
returns an empty string when duration is0
whereapproximate
(old behavior) returnsa few seconds
. I would agree that the old behavior is incorrect, but also probably empty string should return something different (e.g.0.00 seonds
maybe?)? Or is this expected?
text: i18n.translate('data.fieldFormats.duration.outputFormats.humanize', { | ||
defaultMessage: 'Human Readable', | ||
text: i18n.translate('data.fieldFormats.duration.outputFormats.humanize.precise', { | ||
defaultMessage: 'Human Readable precise', |
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.
Nit copy: I think casing should be consistent here. It should either be Human Readable Precise
or Human readable precise
.
As I typing it out autocorrect actually suggesting me that this needs a hyphen. Then how about:
Human-readable (precise)
and Human-readable (approximate)
?
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.
I liked the suggestions. Done
@Dosant so weirdly in case of default output format it doesn't set the output format value in the saved object, it goes as empty. This is why the behavior you are seeing. Will have to find some solution for this. Or otherwise i will leave the default output format as Human readable approx.
|
@Dosant i have reverted the default format to Human-readable approximate to avoid complexities. We can tackle that in a follow up if needs be. |
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.
Retested recent changes. LGTM 👍
…er for duration (elastic#100540) Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
💛 Build succeeded, but was flaky
Test FailuresKibana Pipeline / general / X-Pack API Integration Tests.x-pack/test/api_integration/apis/management/index_management/indices·js.apis management index management indices reload (not on Cloud) should list all the indices with the expected properties and data enrichersStandard Out
Stack Trace
Metrics [docs]Public APIs missing comments
Page load bundle
History
To update your PR or re-run it, just comment with: cc @shahzad31 |
Summary
Closes #94641
Closes #11706
Added a new field formatter in index patterns for duration field to be used in observability use cases
Need to fix for elastic/uptime#327
Also added a use short suffix check box to use short suffix strings in units.
Also aded an option whether to include space between suffix /value
This is how it works on sample data