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

[APM] Fix "Show trace logs" link #41570

Merged
merged 2 commits into from
Jul 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ interface Props {
readonly transaction: Transaction;
}

interface InfraConfigItem {
icon: string;
label: string;
condition?: boolean;
path: string;
query: Record<string, any>;
}

export const TransactionActionMenu: FunctionComponent<Props> = (
props: Props
) => {
Expand All @@ -69,14 +77,14 @@ export const TransactionActionMenu: FunctionComponent<Props> = (
const time = Math.round(transaction.timestamp.us / 1000);
const infraMetricsQuery = getInfraMetricsQuery(transaction);

const infraItems = [
const infraConfigItems: InfraConfigItem[] = [
{
icon: 'loggingApp',
label: i18n.translate(
'xpack.apm.transactionActionMenu.showPodLogsLinkLabel',
{ defaultMessage: 'Show pod logs' }
),
condition: podId,
condition: !!podId,
path: `/link-to/pod-logs/${podId}`,
query: { time }
},
Expand All @@ -86,7 +94,7 @@ export const TransactionActionMenu: FunctionComponent<Props> = (
'xpack.apm.transactionActionMenu.showContainerLogsLinkLabel',
{ defaultMessage: 'Show container logs' }
),
condition: containerId,
condition: !!containerId,
path: `/link-to/container-logs/${containerId}`,
query: { time }
},
Expand All @@ -96,7 +104,7 @@ export const TransactionActionMenu: FunctionComponent<Props> = (
'xpack.apm.transactionActionMenu.showHostLogsLinkLabel',
{ defaultMessage: 'Show host logs' }
),
condition: hostName,
condition: !!hostName,
path: `/link-to/host-logs/${hostName}`,
query: { time }
},
Expand All @@ -107,7 +115,7 @@ export const TransactionActionMenu: FunctionComponent<Props> = (
{ defaultMessage: 'Show trace logs' }
),
condition: true,
hash: `/link-to/logs`,
path: `/link-to/logs`,
Copy link
Member

Choose a reason for hiding this comment

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

Great! Can you also add a type definition like @weltenwort suggested? Just so this doesn't happen again :)

query: { time, filter: `trace.id:${transaction.trace.id}` }
},
{
Expand All @@ -116,7 +124,7 @@ export const TransactionActionMenu: FunctionComponent<Props> = (
'xpack.apm.transactionActionMenu.showPodMetricsLinkLabel',
{ defaultMessage: 'Show pod metrics' }
),
condition: podId,
condition: !!podId,
path: `/link-to/pod-detail/${podId}`,
query: infraMetricsQuery
},
Expand All @@ -126,7 +134,7 @@ export const TransactionActionMenu: FunctionComponent<Props> = (
'xpack.apm.transactionActionMenu.showContainerMetricsLinkLabel',
{ defaultMessage: 'Show container metrics' }
),
condition: containerId,
condition: !!containerId,
path: `/link-to/container-detail/${containerId}`,
query: infraMetricsQuery
},
Expand All @@ -136,20 +144,24 @@ export const TransactionActionMenu: FunctionComponent<Props> = (
'xpack.apm.transactionActionMenu.showHostMetricsLinkLabel',
{ defaultMessage: 'Show host metrics' }
),
condition: hostName,
condition: !!hostName,
path: `/link-to/host-detail/${hostName}`,
query: infraMetricsQuery
}
].map(({ icon, label, condition, path, query }, index) => ({
icon,
key: `infra-link-${index}`,
child: (
<InfraLink path={path} query={query}>
{label}
</InfraLink>
),
condition
}));
];

const infraItems = infraConfigItems.map(
({ icon, label, condition, path, query }, index) => ({
icon,
key: `infra-link-${index}`,
child: (
<InfraLink path={path} query={query}>
{label}
</InfraLink>
),
condition
})
);

const uptimeLink = url.format({
pathname: chrome.addBasePath('/app/uptime'),
Expand All @@ -158,7 +170,7 @@ export const TransactionActionMenu: FunctionComponent<Props> = (
{
dateRangeStart: urlParams.rangeFrom,
dateRangeEnd: urlParams.rangeTo,
search: `url.domain:${idx(transaction, t => t.url.domain)}`
search: `url.domain:"${idx(transaction, t => t.url.domain)}"`
},
(val: string) => !!val
)
Expand Down