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

[Lens] Improve Metric formatter to support bit format #153389

Merged
merged 5 commits into from
Mar 27, 2023

Conversation

dej611
Copy link
Contributor

@dej611 dej611 commented Mar 21, 2023

Summary

Fixes #152014

This PR switches the formatter in the Metric visualization type from the Intl.NumberFormat back to the numeral.js one which supports more units for the bytes and bit format types.

While fixing the referenced issue, this PR also introduced some changes in how the bytes number format is displayed to the user, mainly:

Comparison table

Raw value 8.6 PR Changes
1023 bytes Screenshot 2023-03-21 at 16 29 09 Screenshot 2023-03-21 at 16 27 17 ⚠️
1024 bytes Screenshot 2023-03-21 at 16 29 17 Screenshot 2023-03-21 at 16 27 27 ⚠️
1024 ^ 2 bytes Screenshot 2023-03-21 at 16 29 28 Screenshot 2023-03-21 at 16 27 39 =
1024 ^ 6 bytes Screenshot 2023-03-21 at 16 29 36 Screenshot 2023-03-21 at 16 27 47
1024 ^ 9 bytes Screenshot 2023-03-21 at 16 29 45 Screenshot 2023-03-21 at 16 28 08
999 bits Screenshot 2023-03-21 at 17 55 12 Screenshot 2023-03-21 at 16 27 00
1000 bits Screenshot 2023-03-21 at 17 55 04 Screenshot 2023-03-21 at 16 26 52
1000 ^ 2 bits Screenshot 2023-03-21 at 17 54 54 Screenshot 2023-03-21 at 16 26 40
1000 ^ 6 bits Screenshot 2023-03-21 at 16 30 06 Screenshot 2023-03-21 at 16 26 25
1000 ^ 9 bits Screenshot 2023-03-21 at 16 29 59 Screenshot 2023-03-21 at 16 28 25

Checklist

Delete any items that are not applicable to this PR.

Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.

When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:

Risk Probability Severity Mitigation/Notes
Multiple Spaces—unexpected behavior in non-default Kibana Space. Low High Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces.
Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. High Low Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure.
Code should gracefully handle cases when feature X or plugin Y are disabled. Medium High Unit tests will verify that any feature flag or plugin combination still results in our service operational.
See more potential risk examples

For maintainers

@dej611 dej611 added release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure Feature:Lens v8.8.0 labels Mar 21, 2023
@dej611 dej611 requested a review from drewdaemon March 21, 2023 17:20
@dej611 dej611 marked this pull request as ready for review March 22, 2023 08:42
@dej611 dej611 requested a review from a team as a code owner March 22, 2023 08:42
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-visualizations @elastic/kibana-visualizations-external (Team:Visualizations)

Copy link
Contributor

@drewdaemon drewdaemon left a comment

Choose a reason for hiding this comment

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

Awesome work. I'm happy to see that this change will lead to better format support and consistency with other parts of Kibana. (code review only, lmk if you want me to spin it up)

(serializedFieldFormat?.id === 'suffix'
? serializedFieldFormat.params?.id
: serializedFieldFormat?.id) ?? 'number';
const formatId = getFormatId(serializedFieldFormat) || 'number';
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I'd probably move the number default into getFormatId.

@drewdaemon
Copy link
Contributor

FWIW, I'm wondering if this is an opportunity to reconsider this decision and add a bits field formatter after all. Added an agenda item to the weekly.

@dej611
Copy link
Contributor Author

dej611 commented Mar 24, 2023

I think it can be addressed separately as it will affect all visualization types, not just metric.

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #41 / Cases Configure Closure options change closure option successfully

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
expressionMetricVis 71.5KB 71.3KB -226.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
securitySolution 433 436 +3

Total ESLint disabled count

id before after diff
securitySolution 513 516 +3

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@stratoula
Copy link
Contributor

Yes let's discuss it as a separate issue. We should still merge this PR as it is a very good enhancement

@dej611 dej611 merged commit bac8aac into elastic:main Mar 27, 2023
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Lens release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.8.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Visualizations] Metrics chart not converting averages properly
6 participants