Skip to content

Commit

Permalink
[APM] Fix "Show trace logs" link (#41570)
Browse files Browse the repository at this point in the history
* [APM] Fix "Show trace logs" link

* Add type for infra link items; escape url.domain param for uptime link
  • Loading branch information
dgieselaar authored Jul 23, 2019
1 parent 4e73b18 commit 6999312
Showing 1 changed file with 31 additions and 19 deletions.
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`,
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

0 comments on commit 6999312

Please sign in to comment.