Skip to content

Commit

Permalink
init traces redirection
Browse files Browse the repository at this point in the history
Signed-off-by: Shenoy Pratik <sgguruda@amazon.com>
  • Loading branch information
ps48 committed Oct 18, 2024
1 parent dac7c2c commit 8b23e54
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ 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';
Expand Down Expand Up @@ -69,6 +74,8 @@ 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,
Expand Down Expand Up @@ -172,17 +179,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,
},
});
},
},
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,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}!''))`,
});
};

Expand Down
1 change: 1 addition & 0 deletions public/components/trace_analytics/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export const Home = (props: HomeProps) => {
const dataConnectionLabel = e[0] ? e[0].label : undefined;

if (dataConnectionId !== dataSourceMDSId[0].id) {
console.log('dataConnectionLabel: ', dataConnectionLabel);
setDataSourceMDSId([{ id: dataConnectionId, label: dataConnectionLabel }]);

const currentUrl = window.location.href.split('?')[0];
Expand Down

0 comments on commit 8b23e54

Please sign in to comment.