From 758bbef981b09d178ec88bca5c5183e8f44cb014 Mon Sep 17 00:00:00 2001 From: sumukhswamy Date: Fri, 18 Oct 2024 22:01:31 -0700 Subject: [PATCH] updated paths for re-direction Signed-off-by: sumukhswamy --- .../components/services/service_view.tsx | 41 ++++++++++++++----- .../components/traces/span_detail_flyout.tsx | 3 +- .../components/traces/span_detail_panel.tsx | 5 ++- .../components/traces/trace_view.tsx | 1 + public/components/trace_analytics/home.tsx | 3 +- 5 files changed, 38 insertions(+), 15 deletions(-) diff --git a/public/components/trace_analytics/components/services/service_view.tsx b/public/components/trace_analytics/components/services/service_view.tsx index c4f106d698..2a59150a94 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,28 @@ 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 - }'))`, - }); + 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'))`, + }) + : 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 +554,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 +583,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/span_detail_flyout.tsx b/public/components/trace_analytics/components/traces/span_detail_flyout.tsx index 54e2144a6e..cd0ee27998 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; @@ -309,7 +310,7 @@ export function SpanDetailFlyout(props: { 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}!''))`, + }::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 634c1773f3..86c29fc9ce 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 }; @@ -307,8 +308,8 @@ export function SpanDetailPanel(props: { closeFlyout={() => setCurrentSpan('')} addSpanFilter={addSpanFilter} mode={mode} - dataSourceMDSId={props.dataSourceMDSId} - /> + 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 4707309789..0ec22d0b0f 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 ebe3e4978e..f80d282b45 100644 --- a/public/components/trace_analytics/home.tsx +++ b/public/components/trace_analytics/home.tsx @@ -121,7 +121,7 @@ export const Home = (props: HomeProps) => { // Get existing query params const queryParamsOnLoad = new URLSearchParams(window.location.href.split('?')[1]); const dsFromURL = queryParamsOnLoad.get('datasourceId'); - + const [dataSourceMDSId, setDataSourceMDSId] = useState([ { id: dsFromURL ?? undefined, label: undefined }, ]); @@ -310,6 +310,7 @@ export const Home = (props: HomeProps) => { addSpanFilter={addSpanFilter} mode={spanMode} dataSourceMDSId={spanDataSourceMDSId} + dataSourceMDSLabel={dataSourceMDSId[0].label} /> ); };