Skip to content

Commit

Permalink
[Rum Dashbaord] Rum selected service view (#70579)
Browse files Browse the repository at this point in the history
Co-authored-by: Nathan L Smith <nathan.smith@elastic.co>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 3, 2020
1 parent 169147b commit f1888cd
Show file tree
Hide file tree
Showing 12 changed files with 111 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ Feature: RUM Dashboard
When the user selected the breakdown
Then breakdown series should appear in chart

Scenario: Service name filter
When a user changes the selected service name
Then it displays relevant client metrics
15 changes: 10 additions & 5 deletions x-pack/plugins/apm/e2e/cypress/integration/snapshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ module.exports = {
},
"RUM Dashboard": {
"Client metrics": {
"1": "62 ",
"2": "0.07 sec",
"1": "55 ",
"2": "0.08 sec",
"3": "0.01 sec"
},
"Rum page filters (example #1)": {
"1": "15 ",
"2": "0.07 sec",
"1": "8 ",
"2": "0.08 sec",
"3": "0.01 sec"
},
"Rum page filters (example #2)": {
"1": "35 ",
"1": "28 ",
"2": "0.07 sec",
"3": "0.01 sec"
},
Expand All @@ -31,6 +31,11 @@ module.exports = {
},
"Page load distribution chart legends": {
"1": "Overall"
},
"Service name filter": {
"1": "7 ",
"2": "0.07 sec",
"3": "0.01 sec"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ Given(`a user click page load breakdown filter`, () => {
});

When(`the user selected the breakdown`, () => {
cy.get('[data-cy=filter-breakdown-item_Browser]').click();
cy.get('[data-cy=filter-breakdown-item_Browser]', {
timeout: DEFAULT_TIMEOUT,
}).click();
// click outside popover to close it
cy.get('[data-cy=pageLoadDist]').click();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import { When, Then } from 'cypress-cucumber-preprocessor/steps';
import { DEFAULT_TIMEOUT } from './rum_dashboard';

When(/^the user filters by "([^"]*)"$/, (filterName) => {
// wait for all loading to finish
Expand All @@ -13,9 +14,13 @@ When(/^the user filters by "([^"]*)"$/, (filterName) => {
cy.get(`#local-filter-${filterName}`).click();

if (filterName === 'os') {
cy.get('button.euiSelectableListItem[title="Mac OS X"]').click();
cy.get('button.euiSelectableListItem[title="Mac OS X"]', {
timeout: DEFAULT_TIMEOUT,
}).click();
} else {
cy.get('button.euiSelectableListItem[title="DE"]').click();
cy.get('button.euiSelectableListItem[title="DE"]', {
timeout: DEFAULT_TIMEOUT,
}).click();
}
cy.get('[data-cy=applyFilter]').click();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { When, Then } from 'cypress-cucumber-preprocessor/steps';
import { DEFAULT_TIMEOUT } from '../apm';

When('a user changes the selected service name', (filterName) => {
// wait for all loading to finish
cy.get('kbnLoadingIndicator').should('not.be.visible');
cy.get(`[data-cy=serviceNameFilter]`, { timeout: DEFAULT_TIMEOUT }).select(
'opbean-client-rum'
);
});

Then(`it displays relevant client metrics`, () => {
const clientMetrics = '[data-cy=client-metrics] .euiStat__title';

// wait for all loading to finish
cy.get('kbnLoadingIndicator').should('not.be.visible');
cy.get('.euiStat__title-isLoading').should('not.be.visible');

cy.get(clientMetrics).eq(2).invoke('text').snapshot();

cy.get(clientMetrics).eq(1).invoke('text').snapshot();

cy.get(clientMetrics).eq(0).invoke('text').snapshot();
});
10 changes: 10 additions & 0 deletions x-pack/plugins/apm/e2e/ingest-data/replay.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ function incrementSpinnerCount({ success }) {
spinner.text = `Remaining: ${remaining}. Succeeded: ${requestProgress.succeeded}. Failed: ${requestProgress.failed}.`;
}
let iterIndex = 0;

function setRumAgent(item) {
item.body = item.body.replace(
'"name":"client"',
'"name":"opbean-client-rum"'
);
}

async function insertItem(item) {
try {
const url = `${APM_SERVER_URL}${item.url}`;
Expand All @@ -78,6 +86,8 @@ async function insertItem(item) {

if (item.url === '/intake/v2/rum/events') {
if (iterIndex === userAgents.length) {
// set some event agent to opbean
setRumAgent(item);
iterIndex = 0;
}
headers['User-Agent'] = userAgents[iterIndex];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,13 @@ export const routes: BreadcrumbRoute[] = [
}),
name: RouteName.RUM_OVERVIEW,
},
{
exact: true,
path: '/services/:serviceName/rum-overview',
component: () => <ServiceDetails tab="rum-overview" />,
breadcrumb: i18n.translate('xpack.apm.home.rumOverview.title', {
defaultMessage: 'Real User Monitoring',
}),
name: RouteName.RUM_OVERVIEW,
},
];
23 changes: 16 additions & 7 deletions x-pack/plugins/apm/public/components/app/RumDashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
EuiSpacer,
} from '@elastic/eui';
import React, { useMemo } from 'react';
import { useRouteMatch } from 'react-router-dom';
import { useTrackPageview } from '../../../../../observability/public';
import { LocalUIFilters } from '../../shared/LocalUIFilters';
import { PROJECTION } from '../../../../common/projections/typings';
Expand All @@ -37,6 +38,10 @@ export function RumOverview() {
urlParams: { start, end },
} = useUrlParams();

const isRumServiceRoute = useRouteMatch(
'/services/:serviceName/rum-overview'
);

const { data } = useFetcher(
(callApmApi) => {
if (start && end) {
Expand All @@ -61,13 +66,17 @@ export function RumOverview() {
<EuiFlexGroup>
<EuiFlexItem grow={1}>
<LocalUIFilters {...localUIFiltersConfig} showCount={true}>
<ServiceNameFilter
serviceNames={
data?.items?.map((service) => service.serviceName) ?? []
}
/>
<EuiSpacer size="xl" />
<EuiHorizontalRule margin="none" />
{!isRumServiceRoute && (
<>
<ServiceNameFilter
serviceNames={
data?.items?.map((service) => service.serviceName) ?? []
}
/>
<EuiSpacer size="xl" />
<EuiHorizontalRule margin="none" />{' '}
</>
)}
</LocalUIFilters>
</EuiFlexItem>
<EuiFlexItem grow={7}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ import { ServiceMap } from '../ServiceMap';
import { ServiceMetrics } from '../ServiceMetrics';
import { ServiceNodeOverview } from '../ServiceNodeOverview';
import { TransactionOverview } from '../TransactionOverview';
import { RumOverviewLink } from '../../shared/Links/apm/RumOverviewLink';
import { RumOverview } from '../RumDashboard';
import { RumOverviewLink } from '../../shared/Links/apm/RumOverviewLink';

interface Props {
tab: 'transactions' | 'errors' | 'metrics' | 'nodes' | 'service-map';
tab:
| 'transactions'
| 'errors'
| 'metrics'
| 'nodes'
| 'service-map'
| 'rum-overview';
}

export function ServiceDetailTabs({ tab }: Props) {
Expand Down Expand Up @@ -115,7 +121,7 @@ export function ServiceDetailTabs({ tab }: Props) {
if (isRumAgentName(agentName)) {
tabs.push({
link: (
<RumOverviewLink>
<RumOverviewLink serviceName={serviceName}>
{i18n.translate('xpack.apm.home.rumTabLabel', {
defaultMessage: 'Real User Monitoring',
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,17 @@
*/
import React from 'react';
import { APMLink, APMLinkExtendProps } from './APMLink';
import { useUrlParams } from '../../../../hooks/useUrlParams';
import { pickKeys } from '../../../../../common/utils/pick_keys';

const RumOverviewLink = (props: APMLinkExtendProps) => {
const { urlParams } = useUrlParams();
interface RumOverviewLinkProps extends APMLinkExtendProps {
serviceName?: string;
}
export function RumOverviewLink({
serviceName,
...rest
}: RumOverviewLinkProps) {
const path = serviceName
? `/services/${serviceName}/rum-overview`
: '/rum-overview';

const persistedFilters = pickKeys(
urlParams,
'transactionResult',
'host',
'containerId',
'podName'
);

return <APMLink path="/rum-overview" query={persistedFilters} {...props} />;
};

export { RumOverviewLink };
return <APMLink path={path} {...rest} />;
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const ServiceNameFilter = ({ serviceNames }: Props) => {
<EuiHorizontalRule margin="none" />
<EuiSpacer size="s" />
<EuiSelect
data-cy="serviceNameFilter"
options={options}
value={serviceName}
compressed={true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export function getPathParams(pathname: string = ''): PathParams {
serviceName,
};
case 'service-map':
case 'rum-overview':
return {
serviceName,
};
Expand Down

0 comments on commit f1888cd

Please sign in to comment.