Skip to content

Commit

Permalink
[BUG]Re direction fix for associated logs from traces (opensearch-pro…
Browse files Browse the repository at this point in the history
…ject#2219)

* updated paths for re-direction

Signed-off-by: sumukhswamy <sumukhhs@amazon.com>

* updated paths for re-direction

Signed-off-by: sumukhswamy <sumukhhs@amazon.com>

* updated the title without quotes

Signed-off-by: sumukhswamy <sumukhhs@amazon.com>

* updated linter

Signed-off-by: sumukhswamy <sumukhhs@amazon.com>

* updated snapshots

Signed-off-by: sumukhswamy <sumukhhs@amazon.com>

---------

Signed-off-by: sumukhswamy <sumukhhs@amazon.com>
  • Loading branch information
sumukhswamy authored Oct 19, 2024
1 parent 6edd8ef commit 46ec7f2
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -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,
},
});
}
},
},
]
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -565,6 +585,7 @@ export function ServiceView(props: ServiceViewProps) {
addSpanFilter={addSpanFilter}
mode={mode}
dataSourceMDSId={props.dataSourceMDSId[0].id}
dataSourceMDSLabel={props.dataSourceMDSId[0].label}
/>
)}
</EuiPageBody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ exports[`Trace view component renders trace view 1`] = `
}
}
dataSourceMDSId=""
dataSourceMDSLabel=""
http={[MockFunction]}
mode="data_prepper"
setData={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<React.SetStateAction<string>> | undefined;
startTime?: string;
Expand Down Expand Up @@ -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}!''))`,
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down Expand Up @@ -308,6 +309,7 @@ export function SpanDetailPanel(props: {
addSpanFilter={addSpanFilter}
mode={mode}
dataSourceMDSId={props.dataSourceMDSId}
dataSourceMDSLabel={props.dataSourceMDSLabel}
/>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ export function TraceView(props: TraceViewProps) {
data={ganttData}
setData={setGanttData}
dataSourceMDSId={props.dataSourceMDSId[0].id}
dataSourceMDSLabel={props.dataSourceMDSId[0].label}
/>
</EuiFlexItem>
</EuiFlexGroup>
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 @@ -310,6 +310,7 @@ export const Home = (props: HomeProps) => {
addSpanFilter={addSpanFilter}
mode={spanMode}
dataSourceMDSId={spanDataSourceMDSId}
dataSourceMDSLabel={dataSourceMDSId[0].label}
/>
);
};
Expand Down

0 comments on commit 46ec7f2

Please sign in to comment.