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

[ML] Display advanced mode toggle for the APM failed transactions table #114363

Merged
merged 9 commits into from
Oct 14, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {
EuiBadge,
EuiToolTip,
RIGHT_ALIGNMENT,
EuiSwitch,
EuiIconTip,
} from '@elastic/eui';
import type { EuiTableSortingType } from '@elastic/eui/src/components/basic_table/table_types';
import type { Direction } from '@elastic/eui/src/services/sort/sort_direction';
Expand All @@ -44,7 +46,6 @@ import { useSearchStrategy } from '../../../hooks/use_search_strategy';

import { ImpactBar } from '../../shared/ImpactBar';
import { createHref, push } from '../../shared/Links/url_helpers';
import { Summary } from '../../shared/Summary';

import { CorrelationsTable } from './correlations_table';
import { FailedTransactionsCorrelationsHelpPopover } from './failed_transactions_correlations_help_popover';
Expand All @@ -59,6 +60,8 @@ import { CorrelationsLog } from './correlations_log';
import { CorrelationsEmptyStatePrompt } from './empty_state_prompt';
import { CrossClusterSearchCompatibilityWarning } from './cross_cluster_search_warning';
import { CorrelationsProgressControls } from './progress_controls';
import { useLocalStorage } from '../../../hooks/useLocalStorage';
import { useTheme } from '../../../hooks/use_theme';

export function FailedTransactionsCorrelations({
onFilter,
Expand Down Expand Up @@ -91,18 +94,49 @@ export function FailedTransactionsCorrelations({
selectedSignificantTerm ?? response.failedTransactionsCorrelations?.[0];

const history = useHistory();
const [showStats, setShowStats] = useLocalStorage(
'apmFailedTransactionsShowAdvancedStats',
false
);
const euiTheme = useTheme();

const failedTransactionsCorrelationsColumns: Array<
EuiBasicTableColumn<FailedTransactionsCorrelation>
> = useMemo(() => {
const percentageColumns: Array<
EuiBasicTableColumn<FailedTransactionsCorrelation>
> = inspectEnabled
> = showStats
? [
{
width: '100px',
field: 'pValue',
name: 'p-value',
name: (
<EuiToolTip
content={i18n.translate(
'xpack.apm.correlations.failedTransactions.correlationsTable.pValueDescription',
{
defaultMessage:
'The chance of getting at least this amount of field name and value for failed transactions given its prevalence in successful transactions.',
}
)}
>
<>
{i18n.translate(
'xpack.apm.correlations.failedTransactions.correlationsTable.pValueLabel',
{
defaultMessage: 'p-value',
}
)}
<EuiIcon
size="s"
color="subdued"
type="questionInCircle"
className="eui-alignTop"
/>
</>
</EuiToolTip>
),

render: (pValue: number) => pValue.toPrecision(3),
sortable: true,
},
Expand Down Expand Up @@ -182,7 +216,7 @@ export function FailedTransactionsCorrelations({
name: (
<>
{i18n.translate(
'xpack.apm.correlations.failedTransactions.correlationsTable.pValueLabel',
'xpack.apm.correlations.failedTransactions.correlationsTable.scoreLabel',
{
defaultMessage: 'Score',
}
Expand Down Expand Up @@ -315,7 +349,7 @@ export function FailedTransactionsCorrelations({
},
},
] as Array<EuiBasicTableColumn<FailedTransactionsCorrelation>>;
}, [history, onFilter, trackApmEvent, inspectEnabled]);
}, [history, onFilter, trackApmEvent, showStats]);

useEffect(() => {
if (isErrorMessage(progress.error)) {
Expand Down Expand Up @@ -367,9 +401,6 @@ export function FailedTransactionsCorrelations({
correlationTerms.length < 1 &&
(progressNormalized === 1 || !progress.isRunning);

const showSummaryBadge =
inspectEnabled && (progress.isRunning || correlationTerms.length > 0);

const transactionDistributionChartData: TransactionDistributionChartData[] =
[];

Expand Down Expand Up @@ -462,17 +493,51 @@ export function FailedTransactionsCorrelations({

<EuiSpacer size="s" />

<EuiTitle size="xs">
<span data-test-subj="apmFailedTransactionsCorrelationsTablePanelTitle">
{i18n.translate(
'xpack.apm.correlations.failedTransactions.tableTitle',
{
defaultMessage: 'Correlations',
}
)}
</span>
</EuiTitle>

<EuiFlexGroup gutterSize="s" alignItems="center">
<EuiTitle size="xs">
<span data-test-subj="apmFailedTransactionsCorrelationsTablePanelTitle">
{i18n.translate(
'xpack.apm.correlations.failedTransactions.tableTitle',
{
defaultMessage: 'Correlations',
}
)}
</span>
</EuiTitle>
<EuiFlexItem
style={{
display: 'flex',
flexDirection: 'row',
paddingLeft: euiTheme.eui.paddingSizes.s,
}}
>
<EuiSwitch
Copy link
Contributor

Choose a reason for hiding this comment

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

@qn895 @formgeist is there any value in hiding the switch when no correlations are found?

image

Copy link
Contributor

Choose a reason for hiding this comment

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

@peteharverson I think the result would be that the switch would come and go which can be confusing too

label={i18n.translate(
'xpack.apm.correlations.latencyCorrelations.advancedStatisticsLabel',
{
defaultMessage: 'Advanced statistics',
}
)}
checked={showStats}
onChange={(e) => setShowStats(!showStats)}
Copy link
Member

Choose a reason for hiding this comment

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

can you use a callback here? i.e. setShowState(prevShowStats => !prevShowStats). See https://reactjs.org/docs/hooks-reference.html#functional-updates

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately setShowStats is using useLocalStorage and not useState so this callback doesn't work here. We can modify useLocalStorage to support this behavior but I think that's outside the scope of this PR.

compressed={true}
Copy link
Member

Choose a reason for hiding this comment

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

you can leave out ={true} here and just use compressed

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated here 8477e29

/>
<EuiIconTip
size="m"
iconProps={{
style: { marginLeft: euiTheme.eui.paddingSizes.xs },
}}
content={i18n.translate(
'xpack.apm.correlations.latencyCorrelations.advancedStatisticsTooltipContent',
{
defaultMessage:
'Enable additional statistical information for the correlation results.',
}
)}
type="questionInCircle"
/>
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size="s" />

<CorrelationsProgressControls
Expand All @@ -490,20 +555,6 @@ export function FailedTransactionsCorrelations({
</>
)}

{showSummaryBadge && selectedTerm?.pValue && (
<>
<EuiSpacer size="m" />
<Summary
items={[
<EuiBadge color="hollow">
{`${selectedTerm.fieldName}: ${selectedTerm.fieldValue}`}
</EuiBadge>,
<>{`p-value: ${selectedTerm.pValue.toPrecision(3)}`}</>,
]}
/>
</>
)}

<EuiSpacer size="m" />

<div data-test-subj="apmCorrelationsTable">
Expand Down
20 changes: 10 additions & 10 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -4912,6 +4912,16 @@
"visTypeMetric.colorModes.backgroundOptionLabel": "背景",
"visTypeMetric.colorModes.labelsOptionLabel": "ラベル",
"visTypeMetric.colorModes.noneOptionLabel": "なし",
"visTypeMetric.metricDescription": "計算結果を単独の数字として表示します。",
Copy link
Member

Choose a reason for hiding this comment

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

I assume this is here because some labels were resorted, but it might make sense to undo the changes in these files to prevent merge conflicts (for you or others).

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed here 8477e29

"visTypeMetric.metricTitle": "メトリック",
"visTypeMetric.params.color.useForLabel": "使用する色",
"visTypeMetric.params.rangesTitle": "範囲",
"visTypeMetric.params.settingsTitle": "設定",
"visTypeMetric.params.showTitleLabel": "タイトルを表示",
"visTypeMetric.params.style.fontSizeLabel": "ポイント単位のメトリックフォントサイズ",
"visTypeMetric.params.style.styleTitle": "スタイル",
"visTypeMetric.schemas.metricTitle": "メトリック",
"visTypeMetric.schemas.splitGroupTitle": "グループを分割",
"expressionMetricVis.function.dimension.splitGroup": "グループを分割",
"expressionMetricVis.function.bgFill.help": "html 16 進数コード(#123456)、html 色(red、blue)、または rgba 値(rgba(255,255,255,1))。",
"expressionMetricVis.function.bucket.help": "バケットディメンションの構成です。",
Expand All @@ -4927,16 +4937,6 @@
"expressionMetricVis.function.showLabels.help": "メトリック値の下にラベルを表示します。",
"expressionMetricVis.function.subText.help": "メトリックの下に表示するカスタムテキスト",
"expressionMetricVis.function.useRanges.help": "有効な色範囲です。",
"visTypeMetric.metricDescription": "計算結果を単独の数字として表示します。",
"visTypeMetric.metricTitle": "メトリック",
"visTypeMetric.params.color.useForLabel": "使用する色",
"visTypeMetric.params.rangesTitle": "範囲",
"visTypeMetric.params.settingsTitle": "設定",
"visTypeMetric.params.showTitleLabel": "タイトルを表示",
"visTypeMetric.params.style.fontSizeLabel": "ポイント単位のメトリックフォントサイズ",
"visTypeMetric.params.style.styleTitle": "スタイル",
"visTypeMetric.schemas.metricTitle": "メトリック",
"visTypeMetric.schemas.splitGroupTitle": "グループを分割",
"visTypePie.advancedSettings.visualization.legacyPieChartsLibrary.deprecation": "Visualizeの円グラフのレガシーグラフライブラリは廃止予定であり、8.0以降ではサポートされません。",
"visTypePie.advancedSettings.visualization.legacyPieChartsLibrary.description": "Visualizeで円グラフのレガシーグラフライブラリを有効にします。",
"visTypePie.advancedSettings.visualization.legacyPieChartsLibrary.name": "円グラフのレガシーグラフライブラリ",
Expand Down
20 changes: 10 additions & 10 deletions x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -4957,6 +4957,16 @@
"visTypeMetric.colorModes.backgroundOptionLabel": "背景",
"visTypeMetric.colorModes.labelsOptionLabel": "标签",
"visTypeMetric.colorModes.noneOptionLabel": "无",
"visTypeMetric.metricDescription": "将计算结果显示为单个数字。",
"visTypeMetric.metricTitle": "指标",
"visTypeMetric.params.color.useForLabel": "将颜色用于",
"visTypeMetric.params.rangesTitle": "范围",
"visTypeMetric.params.settingsTitle": "设置",
"visTypeMetric.params.showTitleLabel": "显示标题",
"visTypeMetric.params.style.fontSizeLabel": "指标字体大小(磅)",
"visTypeMetric.params.style.styleTitle": "样式",
"visTypeMetric.schemas.metricTitle": "指标",
"visTypeMetric.schemas.splitGroupTitle": "拆分组",
"expressionMetricVis.function.dimension.splitGroup": "拆分组",
"expressionMetricVis.function.bgFill.help": "将颜色表示为 html 十六进制代码 (#123456)、html 颜色(red、blue)或 rgba 值 (rgba(255,255,255,1))。",
"expressionMetricVis.function.bucket.help": "存储桶维度配置",
Expand All @@ -4972,16 +4982,6 @@
"expressionMetricVis.function.showLabels.help": "在指标值下显示标签。",
"expressionMetricVis.function.subText.help": "要在指标下显示的定制文本",
"expressionMetricVis.function.useRanges.help": "已启用颜色范围。",
"visTypeMetric.metricDescription": "将计算结果显示为单个数字。",
"visTypeMetric.metricTitle": "指标",
"visTypeMetric.params.color.useForLabel": "将颜色用于",
"visTypeMetric.params.rangesTitle": "范围",
"visTypeMetric.params.settingsTitle": "设置",
"visTypeMetric.params.showTitleLabel": "显示标题",
"visTypeMetric.params.style.fontSizeLabel": "指标字体大小(磅)",
"visTypeMetric.params.style.styleTitle": "样式",
"visTypeMetric.schemas.metricTitle": "指标",
"visTypeMetric.schemas.splitGroupTitle": "拆分组",
"visTypePie.advancedSettings.visualization.legacyPieChartsLibrary.deprecation": "Visualize 中饼图的旧版图表库已弃用,自 8.0 后将不受支持。",
"visTypePie.advancedSettings.visualization.legacyPieChartsLibrary.description": "在 Visualize 中启用饼图的旧版图表库。",
"visTypePie.advancedSettings.visualization.legacyPieChartsLibrary.name": "饼图旧版图表库",
Expand Down