From 46ec7f2b974bc6df176174ca12618edf011d16fa Mon Sep 17 00:00:00 2001 From: Sumukh Swamy Date: Sat, 19 Oct 2024 13:32:29 -0700 Subject: [PATCH] [BUG]Re direction fix for associated logs from traces (#2219) * updated paths for re-direction Signed-off-by: sumukhswamy * updated paths for re-direction Signed-off-by: sumukhswamy * updated the title without quotes Signed-off-by: sumukhswamy * updated linter Signed-off-by: sumukhswamy * updated snapshots Signed-off-by: sumukhswamy --------- Signed-off-by: sumukhswamy --- .../components/services/service_view.tsx | 43 ++++++++++++++----- .../__snapshots__/trace_view.test.tsx.snap | 1 + .../components/traces/span_detail_flyout.tsx | 5 ++- .../components/traces/span_detail_panel.tsx | 2 + .../components/traces/trace_view.tsx | 1 + public/components/trace_analytics/home.tsx | 1 + 6 files changed, 40 insertions(+), 13 deletions(-) diff --git a/public/components/trace_analytics/components/services/service_view.tsx b/public/components/trace_analytics/components/services/service_view.tsx index c4f106d69..74165162b 100644 --- a/public/components/trace_analytics/components/services/service_view.tsx +++ b/public/components/trace_analytics/components/services/service_view.tsx @@ -48,6 +48,11 @@ import { SearchBarProps, renderDatePicker } from '../common/search_bar'; import { SpanDetailFlyout } from '../traces/span_detail_flyout'; import { SpanDetailTable } from '../traces/span_detail_table'; import { ServiceMetrics } from './service_metrics'; +import { + DEFAULT_DATA_SOURCE_NAME, + DEFAULT_DATA_SOURCE_TYPE, +} from '../../../../../common/constants/data_sources'; +import { observabilityLogsID } from '../../../../../common/constants/shared'; interface ServiceViewProps extends TraceAnalyticsComponentDeps { serviceName: string; @@ -69,6 +74,7 @@ export function ServiceView(props: ServiceViewProps) { const [redirect, setRedirect] = useState(false); const [actionsMenuPopover, setActionsMenuPopover] = useState(false); + const isNewNavEnabled = coreRefs?.chrome?.navGroup?.getNavGroupEnabled(); const refresh = () => { const DSL = filtersToDsl( mode, @@ -172,17 +178,30 @@ export function ServiceView(props: ServiceViewProps) { name: 'View logs', 'data-test-subj': 'viewLogsButton', onClick: () => { - 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 - }'))`, - }); + if (isNewNavEnabled) { + 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:'${props.dataSourceMDSId[0].label}',type:DATA_SOURCE),id:'${ + props.dataSourceMDSId[0].id ?? '' + }::ss4o_logs-*',timeFieldName:'time',title:'ss4o_logs-*',type:INDEXES),language:PPL,query:'source%20%3D%20ss4o_logs-%2A%20%7C%20where%20serviceName%20%3D%20%22${ + props.serviceName + }%22'))`, + }); + } else { + 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, + }, + }); + } }, }, ] @@ -537,6 +556,7 @@ export function ServiceView(props: ServiceViewProps) { mode={mode} serviceName={props.serviceName} dataSourceMDSId={props.dataSourceMDSId[0].id} + dataSourceMDSLabel={props.dataSourceMDSId[0].label} startTime={props.startTime} endTime={props.endTime} setCurrentSpan={setCurrentSpan} @@ -565,6 +585,7 @@ export function ServiceView(props: ServiceViewProps) { addSpanFilter={addSpanFilter} mode={mode} dataSourceMDSId={props.dataSourceMDSId[0].id} + dataSourceMDSLabel={props.dataSourceMDSId[0].label} /> )} diff --git a/public/components/trace_analytics/components/traces/__tests__/__snapshots__/trace_view.test.tsx.snap b/public/components/trace_analytics/components/traces/__tests__/__snapshots__/trace_view.test.tsx.snap index c29e76ed4..6a72fefc4 100644 --- a/public/components/trace_analytics/components/traces/__tests__/__snapshots__/trace_view.test.tsx.snap +++ b/public/components/trace_analytics/components/traces/__tests__/__snapshots__/trace_view.test.tsx.snap @@ -138,6 +138,7 @@ exports[`Trace view component renders trace view 1`] = ` } } dataSourceMDSId="" + dataSourceMDSLabel="" http={[MockFunction]} mode="data_prepper" setData={[Function]} 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 54e2144a6..65bda8799 100644 --- a/public/components/trace_analytics/components/traces/span_detail_flyout.tsx +++ b/public/components/trace_analytics/components/traces/span_detail_flyout.tsx @@ -79,6 +79,7 @@ export function SpanDetailFlyout(props: { addSpanFilter: (field: string, value: any) => void; mode: TraceAnalyticsMode; dataSourceMDSId: string; + dataSourceMDSLabel: string | undefined; serviceName?: string; setCurrentSelectedService?: React.Dispatch> | undefined; startTime?: string; @@ -307,9 +308,9 @@ export function SpanDetailFlyout(props: { props.startTime },to:${props.endTime}))&_q=(filters:!(),query:(dataset:(dataSource:(id:'${ props.dataSourceMDSId ?? '' - }',title:'',type:DATA_SOURCE),id:'${ + }',title:${props.dataSourceMDSLabel},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}!''))`, + }::ss4o_logs-*',timeFieldName:time,title:'ss4o_logs-*',type:INDEXES),language:PPL,query:'source%20%3D%20ss4o_logs-*%20%7C%20where%20${spanField}%20%3D%20!'${spanId}!''))`, }); }; diff --git a/public/components/trace_analytics/components/traces/span_detail_panel.tsx b/public/components/trace_analytics/components/traces/span_detail_panel.tsx index 634c1773f..9da38b1eb 100644 --- a/public/components/trace_analytics/components/traces/span_detail_panel.tsx +++ b/public/components/trace_analytics/components/traces/span_detail_panel.tsx @@ -30,6 +30,7 @@ export function SpanDetailPanel(props: { colorMap: any; mode: TraceAnalyticsMode; dataSourceMDSId: string; + dataSourceMDSLabel: string | undefined; page?: string; openSpanFlyout?: any; data?: { gantt: any[]; table: any[]; ganttMaxX: number }; @@ -308,6 +309,7 @@ export function SpanDetailPanel(props: { addSpanFilter={addSpanFilter} mode={mode} dataSourceMDSId={props.dataSourceMDSId} + dataSourceMDSLabel={props.dataSourceMDSLabel} /> )} diff --git a/public/components/trace_analytics/components/traces/trace_view.tsx b/public/components/trace_analytics/components/traces/trace_view.tsx index 470730978..340ba7b72 100644 --- a/public/components/trace_analytics/components/traces/trace_view.tsx +++ b/public/components/trace_analytics/components/traces/trace_view.tsx @@ -280,6 +280,7 @@ export function TraceView(props: TraceViewProps) { data={ganttData} setData={setGanttData} dataSourceMDSId={props.dataSourceMDSId[0].id} + dataSourceMDSLabel={props.dataSourceMDSId[0].label} /> diff --git a/public/components/trace_analytics/home.tsx b/public/components/trace_analytics/home.tsx index ebe3e4978..ab3eae139 100644 --- a/public/components/trace_analytics/home.tsx +++ b/public/components/trace_analytics/home.tsx @@ -310,6 +310,7 @@ export const Home = (props: HomeProps) => { addSpanFilter={addSpanFilter} mode={spanMode} dataSourceMDSId={spanDataSourceMDSId} + dataSourceMDSLabel={dataSourceMDSId[0].label} /> ); };