[Uptime] Update show apm data links (#137974) (#137558)

This commit is contained in:
Shahzad 2022-08-09 15:54:46 +01:00 committed by GitHub
parent 0bc8cf7f49
commit 5faf880aa5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 10 deletions

View file

@ -7,7 +7,7 @@ exports[`IntegrationGroup will not display APM links when APM is unavailable 1`]
<EuiFlexItem>
<IntegrationLink
ariaLabel="Search APM for this monitor"
href="/app/apm#/services?kuery=url.domain:%20%22undefined%22&rangeFrom=now-15m&rangeTo=now"
href="/app/apm/services?kuery=url.domain:%20%22undefined%22&rangeFrom=now-15m&rangeTo=now"
iconType="apmApp"
message="Show APM Data"
tooltipContent="Click here to check APM for the domain \\"\\" or explicitly defined \\"service name\\"."
@ -71,7 +71,7 @@ exports[`IntegrationGroup will not display infra links when infra is unavailable
<EuiFlexItem>
<IntegrationLink
ariaLabel="Search APM for this monitor"
href="/app/apm#/services?kuery=url.domain:%20%22undefined%22&rangeFrom=now-15m&rangeTo=now"
href="/app/apm/services?kuery=url.domain:%20%22undefined%22&rangeFrom=now-15m&rangeTo=now"
iconType="apmApp"
message="Show APM Data"
tooltipContent="Click here to check APM for the domain \\"\\" or explicitly defined \\"service name\\"."
@ -135,7 +135,7 @@ exports[`IntegrationGroup will not display logging links when logging is unavail
<EuiFlexItem>
<IntegrationLink
ariaLabel="Search APM for this monitor"
href="/app/apm#/services?kuery=url.domain:%20%22undefined%22&rangeFrom=now-15m&rangeTo=now"
href="/app/apm/services?kuery=url.domain:%20%22undefined%22&rangeFrom=now-15m&rangeTo=now"
iconType="apmApp"
message="Show APM Data"
tooltipContent="Click here to check APM for the domain \\"\\" or explicitly defined \\"service name\\"."

View file

@ -39,14 +39,14 @@ describe('getLegacyApmHref', () => {
it('creates href with base path when present', () => {
const result = getLegacyApmHref(summary, 'foo', 'now-15m', 'now');
expect(result).toMatchInlineSnapshot(
`"foo/app/apm#/services?kuery=url.domain:%20%22www.elastic.co%22&rangeFrom=now-15m&rangeTo=now"`
`"foo/app/apm/services?kuery=url.domain:%20%22www.elastic.co%22&rangeFrom=now-15m&rangeTo=now"`
);
});
it('does not add a base path or extra slash when base path is empty string', () => {
const result = getLegacyApmHref(summary, '', 'now-15m', 'now');
expect(result).toMatchInlineSnapshot(
`"/app/apm#/services?kuery=url.domain:%20%22www.elastic.co%22&rangeFrom=now-15m&rangeTo=now"`
`"/app/apm/services?kuery=url.domain:%20%22www.elastic.co%22&rangeFrom=now-15m&rangeTo=now"`
);
});
@ -59,7 +59,7 @@ describe('getLegacyApmHref', () => {
it('links to the named service', () => {
const result = getLegacyApmHref(summary, 'foo', 'now-15m', 'now');
expect(result).toMatchInlineSnapshot(
`"foo/app/apm#/services?kuery=service.name:%20%22${serviceName}%22&rangeFrom=now-15m&rangeTo=now"`
`"foo/app/apm/services/MyServiceName/overview/?rangeFrom=now-15m&rangeTo=now"`
);
});
});

View file

@ -14,13 +14,20 @@ export const getLegacyApmHref = (
dateRangeStart: string,
dateRangeEnd: string
) => {
const clause = summary?.state?.service?.name
? `service.name: "${summary.state.service.name}"`
: `url.domain: "${summary.state.url?.domain}"`;
const serviceName = summary?.state?.service?.name;
if (serviceName) {
return addBasePath(
basePath,
`/app/apm/services/${serviceName}/overview/?rangeFrom=${dateRangeStart}&rangeTo=${dateRangeEnd}`
);
}
const clause = `url.domain: "${summary.state.url?.domain}"`;
return addBasePath(
basePath,
`/app/apm#/services?kuery=${encodeURI(
`/app/apm/services?kuery=${encodeURI(
clause
)}&rangeFrom=${dateRangeStart}&rangeTo=${dateRangeEnd}`
);