Skip to content

Commit

Permalink
Make infra plugin optional in APM server; Hide links to Infra in the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
crespocarlos committed Sep 6, 2023
1 parent 54ed0a7 commit 138658a
Show file tree
Hide file tree
Showing 9 changed files with 215 additions and 192 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ export function InstanceActionsMenu({
kuery,
onClose,
}: Props) {
const {
core,
infra: { locators },
} = useApmPluginContext();
const { core, infra } = useApmPluginContext();
const { data, status } = useInstanceDetailsFetcher({
serviceName,
serviceNodeName,
Expand Down Expand Up @@ -92,7 +89,7 @@ export function InstanceActionsMenu({
basePath: core.http.basePath,
onFilterByInstanceClick: handleFilterByInstanceClick,
metricsHref,
infraLocators: locators,
infraLocators: infra?.locators,
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,67 +52,71 @@ export function getMenuSections({
? new Date(instanceDetails['@timestamp']).valueOf()
: undefined;
const infraMetricsQuery = getInfraMetricsQuery(instanceDetails['@timestamp']);
const infraNodeLocator = infraLocators.nodeLogsLocator;
const infraNodeLocator = infraLocators?.nodeLogsLocator;

const podActions: Action[] = [
{
key: 'podLogs',
label: i18n.translate(
'xpack.apm.serviceOverview.instancesTable.actionMenus.podLogs',
{ defaultMessage: 'Pod logs' }
),
href: infraNodeLocator.getRedirectUrl({
nodeId: podId!,
nodeType: 'pod',
time,
}),
condition: !!podId,
},
{
key: 'podMetrics',
label: i18n.translate(
'xpack.apm.serviceOverview.instancesTable.actionMenus.podMetrics',
{ defaultMessage: 'Pod metrics' }
),
href: getInfraHref({
app: 'metrics',
basePath,
path: `/link-to/pod-detail/${podId}`,
query: infraMetricsQuery,
}),
condition: !!podId,
},
];
const podActions: Action[] = infraNodeLocator
? [
{
key: 'podLogs',
label: i18n.translate(
'xpack.apm.serviceOverview.instancesTable.actionMenus.podLogs',
{ defaultMessage: 'Pod logs' }
),
href: infraNodeLocator?.getRedirectUrl({
nodeId: podId!,
nodeType: 'pod',
time,
}),
condition: !!podId,
},
{
key: 'podMetrics',
label: i18n.translate(
'xpack.apm.serviceOverview.instancesTable.actionMenus.podMetrics',
{ defaultMessage: 'Pod metrics' }
),
href: getInfraHref({
app: 'metrics',
basePath,
path: `/link-to/pod-detail/${podId}`,
query: infraMetricsQuery,
}),
condition: !!podId,
},
]
: [];

const containerActions: Action[] = [
{
key: 'containerLogs',
label: i18n.translate(
'xpack.apm.serviceOverview.instancesTable.actionMenus.containerLogs',
{ defaultMessage: 'Container logs' }
),
href: infraNodeLocator.getRedirectUrl({
nodeId: containerId!,
nodeType: 'container',
time,
}),
condition: !!containerId,
},
{
key: 'containerMetrics',
label: i18n.translate(
'xpack.apm.serviceOverview.instancesTable.actionMenus.containerMetrics',
{ defaultMessage: 'Container metrics' }
),
href: getInfraHref({
app: 'metrics',
basePath,
path: `/link-to/container-detail/${containerId}`,
query: infraMetricsQuery,
}),
condition: !!containerId,
},
];
const containerActions: Action[] = infraNodeLocator
? [
{
key: 'containerLogs',
label: i18n.translate(
'xpack.apm.serviceOverview.instancesTable.actionMenus.containerLogs',
{ defaultMessage: 'Container logs' }
),
href: infraNodeLocator?.getRedirectUrl({
nodeId: containerId!,
nodeType: 'container',
time,
}),
condition: !!containerId,
},
{
key: 'containerMetrics',
label: i18n.translate(
'xpack.apm.serviceOverview.instancesTable.actionMenus.containerMetrics',
{ defaultMessage: 'Container metrics' }
),
href: getInfraHref({
app: 'metrics',
basePath,
path: `/link-to/container-detail/${containerId}`,
query: infraMetricsQuery,
}),
condition: !!containerId,
},
]
: [];

const apmActions: Action[] = [
{
Expand Down
Loading

0 comments on commit 138658a

Please sign in to comment.