Skip to content

Commit

Permalink
[Uptime] Update show apm data links (#137974) (#137558)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 authored Aug 9, 2022
1 parent 0bc8cf7 commit 5faf880
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.

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 @@ -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"`
);
});

Expand All @@ -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"`
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
);
Expand Down

0 comments on commit 5faf880

Please sign in to comment.