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

[7.x] [Uptime] Use service.name to link from Uptime -> APM where available (#73618) #73666

Merged
merged 2 commits into from
Aug 5, 2020
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions x-pack/plugins/uptime/common/runtime_types/monitor/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export const StateType = t.intersection([
name: t.array(t.string),
}),
}),
service: t.partial({
name: t.string,
}),
}),
]);

Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/uptime/common/runtime_types/ping/ping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ export const PingType = t.intersection([
port: t.number,
scheme: t.string,
}),
service: t.partial({
name: t.string,
}),
}),
]);

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,17 @@ export const IntegrationGroup = ({ summary }: IntegrationGroupProps) => {
href={getApmHref(summary, basePath, dateRangeStart, dateRangeEnd)}
iconType="apmApp"
message={i18n.translate('xpack.uptime.apmIntegrationAction.text', {
defaultMessage: 'Check APM for domain',
defaultMessage: 'Show APM Data',
description:
'A message explaining that when the user clicks the associated link, it will navigate to the APM app and search for the selected domain',
'A message explaining that when the user clicks the associated link, it will navigate to the APM app',
})}
tooltipContent={i18n.translate(
'xpack.uptime.monitorList.observabilityIntegrationsColumn.apmIntegrationLink.tooltip',
{
defaultMessage: 'Click here to check APM for the domain "{domain}".',
defaultMessage:
'Click here to check APM for the domain "{domain}" or explicitly defined "service name".',
description:
'A messsage shown in a tooltip explaining that the nested anchor tag will navigate to the APM app and search for the given URL domain.',
'A messsage shown in a tooltip explaining that the nested anchor tag will navigate to the APM app and search for the given URL domain or explicitly defined service name.',
values: {
domain,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { MonitorSummary, makePing } from '../../../../../common/runtime_types';

describe('getApmHref', () => {
let summary: MonitorSummary;

beforeEach(() => {
summary = {
monitor_id: 'foo',
Expand Down Expand Up @@ -49,4 +48,18 @@ describe('getApmHref', () => {
`"/app/apm#/services?kuery=url.domain:%20%22www.elastic.co%22&rangeFrom=now-15m&rangeTo=now"`
);
});

describe('with service.name', () => {
const serviceName = 'MyServiceName';
beforeEach(() => {
summary.state.service = { name: serviceName };
});

it('links to the named service', () => {
const result = getApmHref(summary, 'foo', 'now-15m', 'now');
expect(result).toMatchInlineSnapshot(
`"foo/app/apm#/services?kuery=service.name:%20%22${serviceName}%22&rangeFrom=now-15m&rangeTo=now"`
);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ export const getApmHref = (
basePath: string,
dateRangeStart: string,
dateRangeEnd: string
) =>
addBasePath(
) => {
const clause = summary?.state?.service?.name
? `service.name: "${summary.state.service.name}"`
: `url.domain: "${summary.state.url?.domain}"`;

return addBasePath(
basePath,
`/app/apm#/services?kuery=${encodeURI(
`url.domain: "${summary?.state?.url?.domain}"`
clause
)}&rangeFrom=${dateRangeStart}&rangeTo=${dateRangeEnd}`
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export const summaryPingsToSummary = (summaryPings: Ping[]): MonitorSummary => {
observer: {
geo: { name: summaryPings.map((p) => p.observer?.geo?.name ?? '').filter((n) => n !== '') },
},
service: summaryPings.find((p) => p.service?.name)?.service,
},
};
};
Expand Down