-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix decimals in diff. flamegraph tooltips (#178524)
In the differential flamegraph tooltips, comparison integer values are shown with decimal digits. This PR fixes it.
- Loading branch information
1 parent
0959783
commit b3064ba
Showing
3 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
x-pack/plugins/observability_solution/profiling/public/utils/formatters/as_integer.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import { asInteger } from './as_integer'; | ||
|
||
describe('asInteger', () => { | ||
it('rounds numbers appropriately', () => { | ||
expect(asInteger(999)).toBe('999'); | ||
|
||
expect(asInteger(1.11)).toBe('1'); | ||
|
||
expect(asInteger(1.5)).toBe('2'); | ||
|
||
expect(asInteger(0.001)).toBe('0'); | ||
|
||
expect(asInteger(0)).toBe('0'); | ||
}); | ||
}); |
10 changes: 10 additions & 0 deletions
10
x-pack/plugins/observability_solution/profiling/public/utils/formatters/as_integer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export function asInteger(value: number) { | ||
return Math.round(value).toString(); | ||
} |