Skip to content

Commit ef53ce0

Browse files
opensearch-trigger-bot[bot]github-actions[bot]Adam Tackett
authored
Services to Traces - Flyout redirection (#2392) (#2393)
* fix redirection services to traces * Add cypress test * remove flakyness --------- (cherry picked from commit ab679de) Signed-off-by: Adam Tackett <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Adam Tackett <[email protected]>
1 parent 337ddc3 commit ef53ce0

File tree

2 files changed

+69
-2
lines changed

2 files changed

+69
-2
lines changed

.cypress/integration/trace_analytics_test/trace_analytics_services.spec.js

+45
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,51 @@ describe('Testing traces Spans table and verify columns functionality', () => {
381381
});
382382
});
383383

384+
describe('Testing navigation from Services to Traces', () => {
385+
beforeEach(() => {
386+
cy.visit('app/observability-traces#/services', {
387+
onBeforeLoad: (win) => {
388+
win.sessionStorage.clear();
389+
},
390+
});
391+
392+
cy.get("[data-test-subj='indexPattern-switch-link']").click();
393+
cy.get("[data-test-subj='data_prepper-mode']").click();
394+
setTimeFilter();
395+
});
396+
397+
it('Clicks on the "Traces" shortcut to redirect', () => {
398+
cy.get('[data-test-subj="globalLoadingIndicator"]').should('not.exist');
399+
cy.get('.euiLink.euiLink--primary').contains('74').click();
400+
cy.get('[data-test-subj="globalLoadingIndicator"]').should('not.exist');
401+
402+
cy.get('[data-test-subj="filterBadge"]')
403+
.should('exist')
404+
.contains('serviceName: analytics-service');
405+
406+
cy.get('.euiText').contains('03f9c770db5ee2f1caac0afc36db49ba').should('exist');
407+
});
408+
409+
it('Opens service flyout, clicks Actions, and selects View Traces', () => {
410+
cy.get('[data-test-subj="globalLoadingIndicator"]').should('not.exist');
411+
cy.get('[data-test-subj*="service-flyout-action-btntrace_service"]')
412+
.should('exist')
413+
.first()
414+
.click();
415+
416+
cy.get('.euiButton').contains('Actions').click();
417+
418+
cy.get('.euiContextMenuItem').contains('View traces').click();
419+
cy.get('[data-test-subj="globalLoadingIndicator"]').should('not.exist');
420+
421+
cy.get('[data-test-subj="filterBadge"]')
422+
.should('exist')
423+
.contains('serviceName: analytics-service');
424+
425+
cy.get('.euiText').contains('03f9c770db5ee2f1caac0afc36db49ba').should('exist');
426+
});
427+
});
428+
384429
describe('Testing switch mode to jaeger', () => {
385430
beforeEach(() => {
386431
cy.visit('app/observability-traces#/services', {

public/components/trace_analytics/components/services/service_view.tsx

+24-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ import {
3535
DEFAULT_DATA_SOURCE_NAME,
3636
DEFAULT_DATA_SOURCE_TYPE,
3737
} from '../../../../../common/constants/data_sources';
38-
import { observabilityLogsID } from '../../../../../common/constants/shared';
38+
import {
39+
observabilityLogsID,
40+
observabilityTracesNewNavID,
41+
} from '../../../../../common/constants/shared';
3942
import { TRACE_ANALYTICS_DATE_FORMAT } from '../../../../../common/constants/trace_analytics';
4043
import { setNavBreadCrumbs } from '../../../../../common/utils/set_nav_bread_crumbs';
4144
import { coreRefs } from '../../../../framework/core_refs';
@@ -80,6 +83,7 @@ export function ServiceView(props: ServiceViewProps) {
8083
const location = useLocation();
8184
const [isServiceOverviewLoading, setIsServiceOverviewLoading] = useState(false);
8285
const [isServicesDataLoading, setIsServicesDataLoading] = useState(false);
86+
const newNavigation = coreRefs.chrome?.navGroup.getNavGroupEnabled();
8387

8488
useEffect(() => {
8589
try {
@@ -165,7 +169,25 @@ export function ServiceView(props: ServiceViewProps) {
165169
inverted: false,
166170
disabled: false,
167171
});
168-
location.assign('#/traces');
172+
173+
const tracesPath = '#/traces';
174+
const dataSourceId = props.dataSourceMDSId[0]?.id || '';
175+
const urlParts = window.location.href.split('?');
176+
const queryParams =
177+
urlParts.length > 1 ? new URLSearchParams(urlParts[1]) : new URLSearchParams();
178+
179+
const modeParam = queryParams.get('mode') || '';
180+
const modeQuery = modeParam ? `&mode=${encodeURIComponent(modeParam)}` : '';
181+
182+
if (newNavigation) {
183+
coreRefs.application?.navigateToApp(observabilityTracesNewNavID, {
184+
path: `${tracesPath}?datasourceId=${encodeURIComponent(dataSourceId)}${modeQuery}`,
185+
});
186+
} else {
187+
window.location.assign(
188+
`${tracesPath}?datasourceId=${encodeURIComponent(dataSourceId)}${modeQuery}`
189+
);
190+
}
169191
};
170192

171193
useEffect(() => {

0 commit comments

Comments
 (0)