Skip to content

Commit

Permalink
quick fix for traces and services indiviudal page (opensearch-project…
Browse files Browse the repository at this point in the history
…#270) (opensearch-project#271)

* quick fix for traces and services indiviudal page

Signed-off-by: Derek Ho <[email protected]>

* remove unecessary import

-off-by: Derek Ho <[email protected]>
Signed-off-by: Derek Ho <[email protected]>

---------

Signed-off-by: Derek Ho <[email protected]>
(cherry picked from commit ec144fa)

Co-authored-by: Derek Ho <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] and derek-ho authored Feb 14, 2023
1 parent 2c75e64 commit b0037cd
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ export function ServiceView(props: ServiceViewProps) {
const [redirect, setRedirect] = useState(false);

const refresh = () => {
const DSL = filtersToDsl(mode, props.filters, props.query, processTimeStamp(props.startTime, mode), processTimeStamp(props.endTime, mode));
const DSL = filtersToDsl(
mode,
props.filters,
props.query,
processTimeStamp(props.startTime, mode),
processTimeStamp(props.endTime, mode)
);
handleServiceViewRequest(props.serviceName, props.http, DSL, setFields, mode);
if (mode === 'data_prepper') {
handleServiceMapRequest(props.http, DSL, mode, setServiceMap, props.serviceName);
Expand All @@ -74,7 +80,7 @@ export function ServiceView(props: ServiceViewProps) {

useEffect(() => {
if (!redirect) refresh();
}, [props.startTime, props.endTime, props.serviceName]);
}, [props.startTime, props.endTime, props.serviceName, props.mode]);

const renderTitle = (
serviceName: string,
Expand Down Expand Up @@ -113,17 +119,19 @@ export function ServiceView(props: ServiceViewProps) {
{props.serviceName || '-'}
</EuiText>
</EuiFlexItem>
{ mode === 'data_prepper' ?
{mode === 'data_prepper' ? (
<EuiFlexItem grow={false}>
<EuiText className="overview-title">Number of connected services</EuiText>
<EuiText size="s" className="overview-content">
{fields.number_of_connected_services !== undefined
? fields.number_of_connected_services
: 0}
</EuiText>
</EuiFlexItem> : <EuiFlexItem/>
}
{ mode === 'data_prepper' ?
</EuiFlexItem>
) : (
<EuiFlexItem />
)}
{mode === 'data_prepper' ? (
<EuiFlexItem grow={false}>
<EuiText className="overview-title">Connected services</EuiText>
<EuiText size="s" className="overview-content">
Expand All @@ -139,8 +147,10 @@ export function ServiceView(props: ServiceViewProps) {
})
: '-'}
</EuiText>
</EuiFlexItem> : <EuiFlexItem/>
}
</EuiFlexItem>
) : (
<EuiFlexItem />
)}
</EuiFlexGroup>
</EuiFlexItem>
<EuiFlexItem>
Expand Down Expand Up @@ -234,17 +244,23 @@ export function ServiceView(props: ServiceViewProps) {
};

useEffect(() => {
const spanDSL = filtersToDsl(mode, props.filters, props.query, processTimeStamp(props.startTime, mode), processTimeStamp(props.endTime, mode));
const spanDSL = filtersToDsl(
mode,
props.filters,
props.query,
processTimeStamp(props.startTime, mode),
processTimeStamp(props.endTime, mode)
);
if (mode === 'data_prepper') {
spanDSL.query.bool.must.push({
term: {
"serviceName": props.serviceName,
serviceName: props.serviceName,
},
});
} else if (mode === 'jaeger') {
spanDSL.query.bool.must.push({
term: {
"process.serviceName": props.serviceName,
'process.serviceName': props.serviceName,
},
});
}
Expand Down Expand Up @@ -325,15 +341,17 @@ export function ServiceView(props: ServiceViewProps) {
<EuiSpacer size="xl" />
{overview}
<EuiSpacer />
{ mode === 'data_prepper' ?
{mode === 'data_prepper' ? (
<ServiceMap
serviceMap={serviceMap}
idSelected={serviceMapIdSelected}
setIdSelected={setServiceMapIdSelected}
currService={props.serviceName}
page="serviceView"
/> : <div/>
}
/>
) : (
<div />
)}
<EuiSpacer />
<EuiPanel>
<PanelTitle title="Spans" totalItems={total} />
Expand Down
35 changes: 26 additions & 9 deletions public/components/trace_analytics/components/traces/trace_view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,16 @@ export function TraceView(props: TraceViewProps) {
</EuiFlexGroup>
)}
</EuiFlexItem>
{ mode === 'data_prepper' ? (
{mode === 'data_prepper' ? (
<EuiFlexItem grow={false}>
<EuiText className="overview-title">Trace group name</EuiText>
<EuiText size="s" className="overview-content">
{fields.trace_group || '-'}
</EuiText>
</EuiFlexItem> ) : (<div/>)
}
</EuiFlexItem>
) : (
<div />
)}
</EuiFlexGroup>
</EuiFlexItem>
<EuiFlexItem>
Expand Down Expand Up @@ -150,10 +152,23 @@ export function TraceView(props: TraceViewProps) {
>('latency');

const refresh = async () => {
const DSL = filtersToDsl(mode, [], '', processTimeStamp('now', mode), processTimeStamp('now', mode), page);
const DSL = filtersToDsl(
mode,
[],
'',
processTimeStamp('now', mode),
processTimeStamp('now', mode),
page
);
handleTraceViewRequest(props.traceId, props.http, fields, setFields, mode);
handlePayloadRequest(props.traceId, props.http, payloadData, setPayloadData, mode);
handleServicesPieChartRequest(props.traceId, props.http, setServiceBreakdownData, setColorMap, mode);
handleServicesPieChartRequest(
props.traceId,
props.http,
setServiceBreakdownData,
setColorMap,
mode
);
handleServiceMapRequest(props.http, DSL, mode, setServiceMap);
};

Expand Down Expand Up @@ -206,7 +221,7 @@ export function TraceView(props: TraceViewProps) {
},
]);
refresh();
}, []);
}, [props.mode]);

return (
<>
Expand Down Expand Up @@ -250,15 +265,17 @@ export function TraceView(props: TraceViewProps) {
) : null}
</EuiPanel>
<EuiSpacer />
{ mode === 'data_prepper' ?
{mode === 'data_prepper' ? (
<ServiceMap
addFilter={undefined}
serviceMap={traceFilteredServiceMap}
idSelected={serviceMapIdSelected}
setIdSelected={setServiceMapIdSelected}
page={page}
/> : (<div/>)
}
/>
) : (
<div />
)}
</EuiPageBody>
</EuiPage>
</>
Expand Down

0 comments on commit b0037cd

Please sign in to comment.