diff --git a/x-pack/plugins/apm/public/components/app/RumDashboard/CoreVitals/CoreVitalItem.tsx b/x-pack/plugins/apm/public/components/app/RumDashboard/CoreVitals/CoreVitalItem.tsx index 22d50ca0d5c41..6107a8e764adb 100644 --- a/x-pack/plugins/apm/public/components/app/RumDashboard/CoreVitals/CoreVitalItem.tsx +++ b/x-pack/plugins/apm/public/components/app/RumDashboard/CoreVitals/CoreVitalItem.tsx @@ -15,11 +15,11 @@ import { i18n } from '@kbn/i18n'; import { PaletteLegends } from './PaletteLegends'; import { ColorPaletteFlexItem } from './ColorPaletteFlexItem'; import { - AVERAGE_LABEL, - GOOD_LABEL, + CV_AVERAGE_LABEL, + CV_GOOD_LABEL, LESS_LABEL, MORE_LABEL, - POOR_LABEL, + CV_POOR_LABEL, } from './translations'; export interface Thresholds { @@ -51,7 +51,7 @@ export function getCoreVitalTooltipMessage( values: { percentage, title: title?.toLowerCase(), - exp: good ? GOOD_LABEL : bad ? POOR_LABEL : AVERAGE_LABEL, + exp: good ? CV_GOOD_LABEL : bad ? CV_POOR_LABEL : CV_AVERAGE_LABEL, moreOrLess: bad || average ? MORE_LABEL : LESS_LABEL, value: good || average ? thresholds.good : thresholds.bad, averageMessage: average @@ -90,7 +90,7 @@ export function CoreVitalItem({ {palette.map((hexCode, ind) => ( diff --git a/x-pack/plugins/apm/public/components/app/RumDashboard/CoreVitals/PaletteLegends.tsx b/x-pack/plugins/apm/public/components/app/RumDashboard/CoreVitals/PaletteLegends.tsx index 84cc5f1ddb230..43eb468b88317 100644 --- a/x-pack/plugins/apm/public/components/app/RumDashboard/CoreVitals/PaletteLegends.tsx +++ b/x-pack/plugins/apm/public/components/app/RumDashboard/CoreVitals/PaletteLegends.tsx @@ -10,16 +10,36 @@ import { EuiFlexItem, EuiHealth, euiPaletteForStatus, + EuiText, EuiToolTip, } from '@elastic/eui'; import styled from 'styled-components'; +import { FormattedMessage } from '@kbn/i18n/react'; +import euiLightVars from '@elastic/eui/dist/eui_theme_light.json'; +import euiDarkVars from '@elastic/eui/dist/eui_theme_dark.json'; import { getCoreVitalTooltipMessage, Thresholds } from './CoreVitalItem'; +import { useUiSetting$ } from '../../../../../../../../src/plugins/kibana_react/public'; +import { + LEGEND_NEEDS_IMPROVEMENT_LABEL, + LEGEND_GOOD_LABEL, + LEGEND_POOR_LABEL, +} from './translations'; const PaletteLegend = styled(EuiHealth)` &:hover { cursor: pointer; text-decoration: underline; - background-color: #e7f0f7; + } +`; + +const StyledSpan = styled.span<{ + darkMode: boolean; +}>` + &:hover { + background-color: ${(props) => + props.darkMode + ? euiDarkVars.euiColorLightestShade + : euiLightVars.euiColorLightestShade}; } `; @@ -36,10 +56,17 @@ export function PaletteLegends({ onItemHover, thresholds, }: Props) { + const [darkMode] = useUiSetting$('theme:darkMode'); + const palette = euiPaletteForStatus(3); + const labels = [ + LEGEND_GOOD_LABEL, + LEGEND_NEEDS_IMPROVEMENT_LABEL, + LEGEND_POOR_LABEL, + ]; return ( - + {palette.map((color, ind) => ( - {ranks?.[ind]}% + + + + {labels[ind]} ({ranks?.[ind]}%) + + + + ))} diff --git a/x-pack/plugins/apm/public/components/app/RumDashboard/CoreVitals/index.tsx b/x-pack/plugins/apm/public/components/app/RumDashboard/CoreVitals/index.tsx index 0135f0b369537..cd7fd0af6d683 100644 --- a/x-pack/plugins/apm/public/components/app/RumDashboard/CoreVitals/index.tsx +++ b/x-pack/plugins/apm/public/components/app/RumDashboard/CoreVitals/index.tsx @@ -8,6 +8,7 @@ import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { CLS_LABEL, FID_LABEL, LCP_LABEL } from './translations'; import { CoreVitalItem } from './CoreVitalItem'; import { UXMetrics } from '../UXMetrics'; +import { formatToSec } from '../UXMetrics/KeyUXMetrics'; const CoreVitalsThresholds = { LCP: { good: '2.5s', bad: '4.0s' }, @@ -28,7 +29,7 @@ export function CoreVitals({ data, loading }: Props) { setIsPopoverOpen(false); + return ( @@ -72,7 +81,37 @@ export function UXMetrics() { -

{I18LABELS.coreWebVitals}

+

+ {I18LABELS.coreWebVitals} + setIsPopoverOpen(true)} + color={'text'} + iconType={'questionInCircle'} + /> + } + closePopover={closePopover} + > +
+ + + + {' '} + {I18LABELS.coreWebVitals} + + +
+
+

diff --git a/x-pack/plugins/apm/server/lib/rum_client/get_long_task_metrics.ts b/x-pack/plugins/apm/server/lib/rum_client/get_long_task_metrics.ts index 812cf9865bda8..bd4bdb9ca3536 100644 --- a/x-pack/plugins/apm/server/lib/rum_client/get_long_task_metrics.ts +++ b/x-pack/plugins/apm/server/lib/rum_client/get_long_task_metrics.ts @@ -81,6 +81,7 @@ export async function getLongTaskMetrics({ } } }); + return { noOfLongTasks, sumOfLongTasks, diff --git a/x-pack/plugins/apm/server/lib/rum_client/get_web_core_vitals.ts b/x-pack/plugins/apm/server/lib/rum_client/get_web_core_vitals.ts index fa34c2e25fecd..0828d7ab65190 100644 --- a/x-pack/plugins/apm/server/lib/rum_client/get_web_core_vitals.ts +++ b/x-pack/plugins/apm/server/lib/rum_client/get_web_core_vitals.ts @@ -124,13 +124,12 @@ export async function getWebCoreVitals({ { value: 0, key: 0 }, ]; - // Divide by 1000 to convert ms into seconds return { cls: String(cls?.values['50.0']?.toFixed(2) || 0), - fid: ((fid?.values['50.0'] || 0) / 1000).toFixed(2), - lcp: ((lcp?.values['50.0'] || 0) / 1000).toFixed(2), - tbt: tbt?.values['50.0'] || 0, - fcp: fcp?.values['50.0'] || 0, + fid: fid?.values['50.0'] ?? 0, + lcp: lcp?.values['50.0'] ?? 0, + tbt: tbt?.values['50.0'] ?? 0, + fcp: fcp?.values['50.0'] ?? 0, lcpRanks: getRanksPercentages(lcpRanks?.values ?? defaultRanks), fidRanks: getRanksPercentages(fidRanks?.values ?? defaultRanks), diff --git a/x-pack/test/apm_api_integration/trial/tests/csm/web_core_vitals.ts b/x-pack/test/apm_api_integration/trial/tests/csm/web_core_vitals.ts index 6364a79a12f04..5825c8fc49a6b 100644 --- a/x-pack/test/apm_api_integration/trial/tests/csm/web_core_vitals.ts +++ b/x-pack/test/apm_api_integration/trial/tests/csm/web_core_vitals.ts @@ -59,13 +59,13 @@ export default function rumServicesApiTests({ getService }: FtrProviderContext) 0, ], "fcp": 1072, - "fid": "1.35", + "fid": 1352.13, "fidRanks": Array [ 0, 0, 100, ], - "lcp": "1.27", + "lcp": 1270.5, "lcpRanks": Array [ 100, 0,