Skip to content

Commit

Permalink
[8.9] [APM] Fix transaction action menu for trace explorer and depend…
Browse files Browse the repository at this point in the history
…ency operations (#162213) (#162260)

# Backport

This will backport the following commits from `main` to `8.9`:
- [[APM] Fix transaction action menu for trace explorer and dependency
operations (#162213)](#162213)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Giorgos
Bamparopoulos","email":"georgios.bamparopoulos@elastic.co"},"sourceCommit":{"committedDate":"2023-07-19T15:25:08Z","message":"[APM]
Fix transaction action menu for trace explorer and dependency operations
(#162213)\n\n###
Before\r\n\r\nhttps://github.com/elastic/kibana/assets/5831975/3fcceac7-6cf6-4060-972e-86fc4c799115\r\n\r\n###
After\r\n\r\nhttps://github.com/elastic/kibana/assets/5831975/0eccce82-4ffc-4c9e-8f8f-baf89cfbccec\r\n\r\n\r\nCloses
#162175:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"a8f9f73e19c6f5b6826a6a8f7752059659a5142d","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:APM","backport:prev-minor","v8.10.0"],"number":162213,"url":"#162213
Fix transaction action menu for trace explorer and dependency operations
(#162213)\n\n###
Before\r\n\r\nhttps://github.com/elastic/kibana/assets/5831975/3fcceac7-6cf6-4060-972e-86fc4c799115\r\n\r\n###
After\r\n\r\nhttps://github.com/elastic/kibana/assets/5831975/0eccce82-4ffc-4c9e-8f8f-baf89cfbccec\r\n\r\n\r\nCloses
#162175:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"a8f9f73e19c6f5b6826a6a8f7752059659a5142d"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"#162213
Fix transaction action menu for trace explorer and dependency operations
(#162213)\n\n###
Before\r\n\r\nhttps://github.com/elastic/kibana/assets/5831975/3fcceac7-6cf6-4060-972e-86fc4c799115\r\n\r\n###
After\r\n\r\nhttps://github.com/elastic/kibana/assets/5831975/0eccce82-4ffc-4c9e-8f8f-baf89cfbccec\r\n\r\n\r\nCloses
#162175:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"a8f9f73e19c6f5b6826a6a8f7752059659a5142d"}}]}]
BACKPORT-->
  • Loading branch information
gbamparop committed Jul 20, 2023
1 parent f04aab7 commit 7c5bbe6
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 7 deletions.
@@ -0,0 +1,49 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import url from 'url';
import { synthtrace } from '../../../../synthtrace';
import { opbeans } from '../../../fixtures/synthtrace/opbeans';

const start = '2021-10-10T00:00:00.000Z';
const end = '2021-10-10T00:15:00.000Z';

const dependencyOperationHref = url.format({
pathname: '/app/apm/dependencies/operation',
query: {
dependencyName: 'postgresql',
spanName: 'SELECT * FROM product',
environment: 'ENVIRONMENT_ALL',
rangeFrom: start,
rangeTo: end,
},
});

describe('Dependency operation', () => {
before(() => {
synthtrace.index(
opbeans({
from: new Date(start).getTime(),
to: new Date(end).getTime(),
})
);
});

after(() => {
synthtrace.clean();
});

beforeEach(() => {
cy.loginAsViewerUser();
});

it('opens the action menu popup when clicking the investigate button', () => {
cy.visitKibana(dependencyOperationHref);
cy.getByTestSubj('apmActionMenuButtonInvestigateButton').click();
cy.getByTestSubj('apmActionMenuInvestigateButtonPopup');
});
});
@@ -0,0 +1,47 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import url from 'url';
import { synthtrace } from '../../../../synthtrace';
import { generateMobileData } from './generate_data';

const start = '2021-10-10T00:00:00.000Z';
const end = '2021-10-10T00:15:00.000Z';

const mobileTransactionDetailsPageHref = url.format({
pathname: '/app/apm/mobile-services/synth-android/transactions/view',
query: {
rangeFrom: start,
rangeTo: end,
transactionName: 'Start View - View Appearing',
},
});

describe('Mobile transaction details page', () => {
before(() => {
synthtrace.index(
generateMobileData({
from: new Date(start).getTime(),
to: new Date(end).getTime(),
})
);
});

beforeEach(() => {
cy.loginAsViewerUser();
});

after(() => {
synthtrace.clean();
});

it('opens the action menu popup when clicking the investigate button', () => {
cy.visitKibana(mobileTransactionDetailsPageHref);
cy.getByTestSubj('apmActionMenuButtonInvestigateButton').click();
cy.getByTestSubj('apmActionMenuInvestigateButtonPopup');
});
});
@@ -0,0 +1,51 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import url from 'url';
import { synthtrace } from '../../../../synthtrace';
import { opbeans } from '../../../fixtures/synthtrace/opbeans';

const start = '2021-10-10T00:00:00.000Z';
const end = '2021-10-10T00:15:00.000Z';

const traceExplorerHref = url.format({
pathname: '/app/apm/traces/explorer',
query: {
environment: 'ENVIRONMENT_ALL',
rangeFrom: start,
rangeTo: end,
},
});

describe('Trace Explorer', () => {
before(() => {
synthtrace.index(
opbeans({
from: new Date(start).getTime(),
to: new Date(end).getTime(),
})
);

cy.updateAdvancedSettings({
'observability:apmTraceExplorerTab': true,
});
});

after(() => {
synthtrace.clean();
});

beforeEach(() => {
cy.loginAsViewerUser();
});

it('opens the action menu popup when clicking the investigate button', () => {
cy.visitKibana(traceExplorerHref);
cy.getByTestSubj('apmActionMenuButtonInvestigateButton').click();
cy.getByTestSubj('apmActionMenuInvestigateButtonPopup');
});
});
Expand Up @@ -62,6 +62,9 @@ describe('Transaction action menu', () => {
apmRouter,
infraLocators,
infraLinksAvailable: false,
rangeFrom: 'now-24h',
rangeTo: 'now',
environment: 'ENVIRONMENT_ALL',
})
).toEqual([
[
Expand Down Expand Up @@ -124,6 +127,9 @@ describe('Transaction action menu', () => {
apmRouter,
infraLocators,
infraLinksAvailable: true,
rangeFrom: 'now-24h',
rangeTo: 'now',
environment: 'ENVIRONMENT_ALL',
})
).toEqual([
[
Expand Down Expand Up @@ -205,6 +211,9 @@ describe('Transaction action menu', () => {
apmRouter,
infraLocators,
infraLinksAvailable: true,
rangeFrom: 'now-24h',
rangeTo: 'now',
environment: 'ENVIRONMENT_ALL',
})
).toEqual([
[
Expand Down
Expand Up @@ -12,6 +12,7 @@ import { isEmpty, pickBy } from 'lodash';
import moment from 'moment';
import url from 'url';
import type { InfraLocators } from '@kbn/infra-plugin/common/locators';
import { Environment } from '../../../../common/environment_rt';
import type { Transaction } from '../../../../typings/es_schemas/ui/transaction';
import { getDiscoverHref } from '../links/discover_links/discover_link';
import { getDiscoverQuery } from '../links/discover_links/discover_transaction_link';
Expand All @@ -38,13 +39,19 @@ export const getSections = ({
apmRouter,
infraLocators,
infraLinksAvailable,
rangeFrom,
rangeTo,
environment,
}: {
transaction?: Transaction;
basePath: IBasePath;
location: Location;
apmRouter: ApmRouter;
infraLocators: InfraLocators;
infraLinksAvailable: boolean;
rangeFrom: string;
rangeTo: string;
environment: Environment;
}) => {
if (!transaction) return [];
const hostName = transaction.host?.hostname;
Expand All @@ -55,12 +62,6 @@ export const getSections = ({
const time = Math.round(transaction.timestamp.us / 1000);
const infraMetricsQuery = getInfraMetricsQuery(transaction);

const routeParams = apmRouter.getParams(
'/services/{serviceName}/transactions/view',
location
);
const { rangeFrom, rangeTo, environment } = routeParams.query;

const uptimeLink = url.format({
pathname: basePath.prepend('/app/uptime'),
search: `?${fromQuery(
Expand Down
Expand Up @@ -21,6 +21,7 @@ import { getContextMenuItemsFromActions } from '@kbn/observability-shared-plugin
import React, { useState } from 'react';
import { useLocation } from 'react-router-dom';
import useAsync from 'react-use/lib/useAsync';
import { useAnyOfApmParams } from '../../../hooks/use_apm_params';
import { ApmFeatureFlagName } from '../../../../common/apm_feature_flags';
import { Transaction } from '../../../../typings/es_schemas/ui/transaction';
import { useApmPluginContext } from '../../../context/apm_plugin/use_apm_plugin_context';
Expand Down Expand Up @@ -101,13 +102,25 @@ function ActionMenuSections({ transaction }: { transaction?: Transaction }) {
ApmFeatureFlagName.InfraUiAvailable
);

const {
query: { rangeFrom, rangeTo, environment },
} = useAnyOfApmParams(
'/services/{serviceName}/transactions/view',
'/mobile-services/{serviceName}/transactions/view',
'/traces/explorer/waterfall',
'/dependencies/operation'
);

const sections = getSections({
transaction,
basePath: core.http.basePath,
location,
apmRouter,
infraLocators: locators,
infraLinksAvailable,
rangeFrom,
rangeTo,
environment,
});

const externalMenuItems = useAsync(() => {
Expand Down Expand Up @@ -138,7 +151,7 @@ function ActionMenuSections({ transaction }: { transaction?: Transaction }) {
}

return (
<div>
<div data-test-subj="apmActionMenuInvestigateButtonPopup">
{sections.map((section, idx) => {
const isLastSection = idx !== sections.length - 1;
return (
Expand Down

0 comments on commit 7c5bbe6

Please sign in to comment.