Skip to content

Commit

Permalink
[ML] Fix APM latency order of sticky header properties, add help popo…
Browse files Browse the repository at this point in the history
…ver (#103759) (#105473)

* [ML] APM latency correlations help popover

* Remove spacer

* [ML] Updates correlation tooltip

* Remove scss, use styled popover instead

* Fix order to be Service > Environment > Transaction

* Addresses popover text feedback

* Addresses more popover text feedback

* Adds performance warning to popover; improves tooltip

* Internationalizes aria label in popover

* Internationalizes aria label in ML popover

Co-authored-by: Quynh Nguyen <quynh.nguyen@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Quynh Nguyen <quynh.nguyen@elastic.co>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
3 people committed Jul 13, 2021
1 parent 51bbee1 commit b8ff424
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 25 deletions.
22 changes: 12 additions & 10 deletions x-pack/plugins/apm/public/components/app/correlations/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,7 @@ export function Correlations() {
width: '20%',
});
}
if (urlParams.transactionName) {
properties.push({
label: i18n.translate('xpack.apm.correlations.transactionLabel', {
defaultMessage: 'Transaction',
}),
fieldName: TRANSACTION_NAME,
val: urlParams.transactionName,
width: '20%',
});
}

if (urlParams.environment) {
properties.push({
label: i18n.translate('xpack.apm.correlations.environmentLabel', {
Expand All @@ -125,6 +116,17 @@ export function Correlations() {
});
}

if (urlParams.transactionName) {
properties.push({
label: i18n.translate('xpack.apm.correlations.transactionLabel', {
defaultMessage: 'Transaction',
}),
fieldName: TRANSACTION_NAME,
val: urlParams.transactionName,
width: '20%',
});
}

return properties;
}, [serviceName, urlParams.environment, urlParams.transactionName]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { useCorrelations } from './use_correlations';
import { push } from '../../shared/Links/url_helpers';
import { useUiTracker } from '../../../../../observability/public';
import { asPreciseDecimal } from '../../../../common/utils/formatters';
import { LatencyCorrelationsHelpPopover } from './ml_latency_correlations_help_popover';

const DEFAULT_PERCENTILE_THRESHOLD = 95;
const isErrorMessage = (arg: unknown): arg is Error => {
Expand Down Expand Up @@ -151,7 +152,7 @@ export function MlLatencyCorrelations({ onClose }: Props) {
'xpack.apm.correlations.latencyCorrelations.correlationsTable.correlationColumnDescription',
{
defaultMessage:
'The impact of a field on the latency of the service, ranging from 0 to 1.',
'The correlation score [0-1] of an attribute; the greater the score, the more an attribute increases latency.',
}
)}
>
Expand Down Expand Up @@ -263,20 +264,6 @@ export function MlLatencyCorrelations({ onClose }: Props) {

return (
<>
<EuiText size="s" color="subdued">
<p>
{i18n.translate(
'xpack.apm.correlations.latencyCorrelations.description',
{
defaultMessage:
'What is slowing down my service? Correlations will help discover a slower performance in a particular cohort of your data.',
}
)}
</p>
</EuiText>

<EuiSpacer size="m" />

<EuiFlexGroup>
<EuiFlexItem grow={false}>
{!isRunning && (
Expand Down Expand Up @@ -320,6 +307,9 @@ export function MlLatencyCorrelations({ onClose }: Props) {
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<LatencyCorrelationsHelpPopover />
</EuiFlexItem>
</EuiFlexGroup>

<EuiSpacer size="m" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* 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 React, { useState } from 'react';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { HelpPopover, HelpPopoverButton } from '../help_popover/help_popover';

export function LatencyCorrelationsHelpPopover() {
const [isPopoverOpen, setIsPopoverOpen] = useState(false);

return (
<HelpPopover
anchorPosition="leftUp"
button={
<HelpPopoverButton
onClick={() => {
setIsPopoverOpen(!isPopoverOpen);
}}
/>
}
closePopover={() => setIsPopoverOpen(false)}
isOpen={isPopoverOpen}
title={i18n.translate('xpack.apm.correlations.latencyPopoverTitle', {
defaultMessage: 'Latency correlations',
})}
>
<p>
<FormattedMessage
id="xpack.apm.correlations.latencyPopoverBasicExplanation"
defaultMessage="Correlations help you discover which attributes are contributing to increased transaction response times or latency."
/>
</p>
<p>
<FormattedMessage
id="xpack.apm.correlations.latencyPopoverChartExplanation"
defaultMessage="The latency distribution chart visualizes the overall latency of the transactions in the service. When you hover over attributes in the table, their latency distribution is added to the chart."
/>
</p>
<p>
<FormattedMessage
id="xpack.apm.correlations.latencyPopoverTableExplanation"
defaultMessage="The table is sorted by correlation coefficients that range from 0 to 1. Attributes with higher correlation values are more likely to contribute to high latency transactions."
/>
</p>
<p>
<FormattedMessage
id="xpack.apm.correlations.latencyPopoverPerformanceExplanation"
defaultMessage="This analysis performs statistical searches across a large number of attributes. For large time ranges and services with high transaction throughput, this might take some time. Reduce the time range to improve performance."
/>
</p>
<p>
<FormattedMessage
id="xpack.apm.correlations.latencyPopoverFilterExplanation"
defaultMessage="You can also add or remove filters to affect the queries in the APM app."
/>
</p>
</HelpPopover>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* 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 React, { ReactNode } from 'react';
import { i18n } from '@kbn/i18n';
import {
EuiButtonIcon,
EuiLinkButtonProps,
EuiPopover,
EuiPopoverProps,
EuiPopoverTitle,
EuiText,
} from '@elastic/eui';
import { euiStyled } from '../../../../../../../src/plugins/kibana_react/common';

const PopoverContent = euiStyled(EuiText)`
max-width: 480px;
max-height: 40vh;
`;

export function HelpPopoverButton({
onClick,
}: {
onClick: EuiLinkButtonProps['onClick'];
}) {
return (
<EuiButtonIcon
className="apmHelpPopover__buttonIcon"
size="s"
iconType="help"
aria-label={i18n.translate('xpack.apm.helpPopover.ariaLabel', {
defaultMessage: 'Help',
})}
onClick={onClick}
/>
);
}

export function HelpPopover({
anchorPosition,
button,
children,
closePopover,
isOpen,
title,
}: {
anchorPosition?: EuiPopoverProps['anchorPosition'];
button: EuiPopoverProps['button'];
children: ReactNode;
closePopover: EuiPopoverProps['closePopover'];
isOpen: EuiPopoverProps['isOpen'];
title?: string;
}) {
return (
<EuiPopover
anchorPosition={anchorPosition}
button={button}
closePopover={closePopover}
isOpen={isOpen}
panelPaddingSize="s"
ownFocus
>
{title && <EuiPopoverTitle paddingSize="s">{title}</EuiPopoverTitle>}

<PopoverContent size="s">{children}</PopoverContent>
</EuiPopover>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* 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 { HelpPopoverButton, HelpPopover } from './help_popover';
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import React, { ReactNode } from 'react';
import { i18n } from '@kbn/i18n';
import {
EuiButtonIcon,
EuiLinkButtonProps,
Expand All @@ -22,6 +23,9 @@ export const HelpPopoverButton = ({ onClick }: { onClick: EuiLinkButtonProps['on
className="mlHelpPopover__buttonIcon"
size="s"
iconType="help"
aria-label={i18n.translate('xpack.ml.helpPopover.ariaLabel', {
defaultMessage: 'Help',
})}
onClick={onClick}
/>
);
Expand Down

0 comments on commit b8ff424

Please sign in to comment.