From 6fb112c5fd0be101961a4002f6d76f9faae43a90 Mon Sep 17 00:00:00 2001 From: Paul Sebastian Date: Tue, 15 Oct 2024 10:49:37 -0700 Subject: [PATCH] Update traces span redirection (#2201) * modify traces span redirection to discover instead of explorer Signed-off-by: Paul Sebastian * update the traces span redirection to use discover Signed-off-by: Paul Sebastian * update services redirection Signed-off-by: Paul Sebastian * prevent rison decoding failure Signed-off-by: Paul Sebastian --------- Signed-off-by: Paul Sebastian --- .../components/services/service_view.tsx | 24 ++++++++----------- .../components/traces/span_detail_flyout.tsx | 22 +++++++---------- 2 files changed, 18 insertions(+), 28 deletions(-) diff --git a/public/components/trace_analytics/components/services/service_view.tsx b/public/components/trace_analytics/components/services/service_view.tsx index 01e565215..c4f106d69 100644 --- a/public/components/trace_analytics/components/services/service_view.tsx +++ b/public/components/trace_analytics/components/services/service_view.tsx @@ -28,11 +28,6 @@ import round from 'lodash/round'; import React, { useEffect, useMemo, useState } from 'react'; import { DataSourceManagementPluginSetup } from '../../../../../../../src/plugins/data_source_management/public'; import { DataSourceOption } from '../../../../../../../src/plugins/data_source_management/public/components/data_source_menu/types'; -import { - DEFAULT_DATA_SOURCE_NAME, - DEFAULT_DATA_SOURCE_TYPE, -} from '../../../../../common/constants/data_sources'; -import { observabilityLogsID } from '../../../../../common/constants/shared'; import { setNavBreadCrumbs } from '../../../../../common/utils/set_nav_bread_crumbs'; import { coreRefs } from '../../../../framework/core_refs'; import { HeaderControlledComponentsWrapper } from '../../../../plugin_helpers/plugin_headerControl'; @@ -177,15 +172,16 @@ export function ServiceView(props: ServiceViewProps) { name: 'View logs', 'data-test-subj': 'viewLogsButton', onClick: () => { - coreRefs?.application!.navigateToApp(observabilityLogsID, { - path: `#/explorer`, - state: { - DEFAULT_DATA_SOURCE_NAME, - DEFAULT_DATA_SOURCE_TYPE, - queryToRun: `source = ss4o_logs-* | where serviceName='${props.serviceName}'`, - startTimeRange: props.startTime, - endTimeRange: props.endTime, - }, + coreRefs?.application!.navigateToApp('data-explorer', { + path: `discover#?_a=(discover:(columns:!(_source),isDirty:!f,sort:!()),metadata:(view:discover))&_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:${ + props.startTime + },to:${props.endTime}))&_q=(filters:!(),query:(dataset:(dataSource:(id:'${ + props.dataSourceMDSId[0].id ?? '' + }',title:'',type:DATA_SOURCE),id:'${ + props.dataSourceMDSId[0].id + }::ss4o_logs-*',timeFieldName:'%40timestamp',title:'ss4o_logs-*',type:INDEXES),language:PPL,query:'source%20%3D%20ss4o_logs-*%20%7C%20where%20serviceName%20%3D%20${ + props.serviceName + }'))`, }); }, }, diff --git a/public/components/trace_analytics/components/traces/span_detail_flyout.tsx b/public/components/trace_analytics/components/traces/span_detail_flyout.tsx index 47e04cac0..54e2144a6 100644 --- a/public/components/trace_analytics/components/traces/span_detail_flyout.tsx +++ b/public/components/trace_analytics/components/traces/span_detail_flyout.tsx @@ -23,11 +23,6 @@ import round from 'lodash/round'; import moment from 'moment'; import React, { useEffect, useState } from 'react'; import { HttpSetup } from '../../../../../../../src/core/public'; -import { - DEFAULT_DATA_SOURCE_NAME, - DEFAULT_DATA_SOURCE_TYPE, -} from '../../../../../common/constants/data_sources'; -import { observabilityLogsID } from '../../../../../common/constants/shared'; import { TRACE_ANALYTICS_DATE_FORMAT } from '../../../../../common/constants/trace_analytics'; import { SpanField, TraceAnalyticsMode } from '../../../../../common/types/trace_analytics'; import { coreRefs } from '../../../../framework/core_refs'; @@ -307,15 +302,14 @@ export function SpanDetailFlyout(props: { const redirectToExplorer = () => { const spanId = getSpanValue(span, mode, 'SPAN_ID'); const spanField = getSpanFieldKey(mode, 'SPAN_ID'); - coreRefs?.application!.navigateToApp(observabilityLogsID, { - path: `#/explorer`, - state: { - DEFAULT_DATA_SOURCE_NAME, - DEFAULT_DATA_SOURCE_TYPE, - queryToRun: `source = ss4o_logs-* | where ${spanField}='${spanId}'`, - startTimeRange: props.startTime, - endTimeRange: props.endTime, - }, + coreRefs?.application!.navigateToApp('data-explorer', { + path: `discover#?_a=(discover:(columns:!(_source),isDirty:!f,sort:!()),metadata:(view:discover))&_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:${ + props.startTime + },to:${props.endTime}))&_q=(filters:!(),query:(dataset:(dataSource:(id:'${ + props.dataSourceMDSId ?? '' + }',title:'',type:DATA_SOURCE),id:'${ + props.dataSourceMDSId + }::ss4o_logs-*',timeFieldName:'%40timestamp',title:'ss4o_logs-*',type:INDEXES),language:PPL,query:'source%20%3D%20ss4o_logs-*%20%7C%20where%20${spanField}%20%3D%20!'${spanId}!''))`, }); };