Skip to content

Commit

Permalink
address PR review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Ho <[email protected]>
  • Loading branch information
derek-ho committed Aug 29, 2023
1 parent 542b944 commit e9941e0
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .cypress/integration/4_trace_analytics_dashboard.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ describe('Testing plots', () => {
cy.get('.vis-network').should('exist');

cy.get('.euiButton__text[title="Errors"]').click();
cy.get('text.ytitle[data-unformatted="Error rate"]').should('exist');
cy.get('text.ytitle[data-unformatted="Error rate (%)"]').should('exist');

cy.get('.euiButton__text[title="Request Rate"]').click();
cy.get('text.ytitle[data-unformatted="Request rate"]').should('exist');
cy.get('text.ytitle[data-unformatted="Request rate (spans)"]').should('exist');
cy.get('text[data-unformatted="50"]').should('exist');

cy.get('input[type="search"]').eq(1).focus().type('payment{enter}');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export function ServiceMapScale(props: {
const delta = ticks[1] - ticks[0];
const title = {
latency: 'Average duration (ms)',
error_rate: 'Error rate',
throughput: 'Request rate',
error_rate: 'Error rate (%)',
throughput: 'Request rate (spans)',
}[props.idSelected];
const percentInterval = 1 / Math.max(ticks.length - 1, 1);
const percents = Array.from({ length: ticks.length - 1 }, (v, i) => percentInterval * i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function TopGroupsPage(props: {
},
{
id: 'throughput',
label: 'Rate',
label: 'Request rate',
'data-test-subj': 'throughput-toggle'
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function ServicesContent(props: ServicesProps) {
} = props;
const [tableItems, setTableItems] = useState([]);

const [trigger, setTrigger] = useState<'open' | 'closed' | undefined>('closed');
const [trigger, setTrigger] = useState<'open' | 'closed'>('closed');
const [serviceMap, setServiceMap] = useState<ServiceObject>({});
const [serviceMapIdSelected, setServiceMapIdSelected] = useState<
'latency' | 'error_rate' | 'throughput'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const handleDashboardRequest = async (
.catch((error) => console.error(error));
if (setPercentileMap) setPercentileMap(latencyVariances);

const latencyTrends = await handleDslRequest(http, latencyTrendDSL, getLatencyTrendQuery(), mode, true, setShowTimeoutToast)
const latencyTrends = await handleDslRequest(http, latencyTrendDSL, getLatencyTrendQuery(), mode, setShowTimeoutToast)
.then((response) => {
const map: any = {};
response.aggregations.trace_group_name.buckets.map((bucket) => {
Expand Down Expand Up @@ -105,7 +105,7 @@ export const handleDashboardRequest = async (
})
.catch((error) => console.error(error));

await handleDslRequest(http, DSL, getDashboardQuery(), mode, true, setShowTimeoutToast)
await handleDslRequest(http, DSL, getDashboardQuery(), mode, setShowTimeoutToast)
.then((response) => {
return Promise.all(
response.aggregations.trace_group_name.buckets.map((bucket) => {
Expand Down Expand Up @@ -138,7 +138,7 @@ export const handleJaegerDashboardRequest = async (
setShowTimeoutToast,
setPercentileMap?
) => {
const latencyTrends = await handleDslRequest(http, latencyTrendDSL, getJaegerLatencyTrendQuery(), mode, true, setShowTimeoutToast)
const latencyTrends = await handleDslRequest(http, latencyTrendDSL, getJaegerLatencyTrendQuery(), mode, setShowTimeoutToast)
.then((response) => {
const map: any = {};
response.aggregations.trace_group_name.buckets.map((bucket) => {
Expand Down Expand Up @@ -195,7 +195,7 @@ export const handleJaegerDashboardRequest = async (
console.error(error);
});

await handleDslRequest(http, DSL, getJaegerDashboardQuery(), mode, true, setShowTimeoutToast)
await handleDslRequest(http, DSL, getJaegerDashboardQuery(), mode, setShowTimeoutToast)
.then((response) => {
return Promise.all(
response.aggregations.trace_group_name.buckets.map((bucket) => {
Expand Down Expand Up @@ -249,7 +249,7 @@ export const handleJaegerErrorDashboardRequest = async (
setShowTimeoutToast,
setPercentileMap?
) => {
const errorTrends = await handleDslRequest(http, latencyTrendDSL, getJaegerErrorTrendQuery(), mode, true, setShowTimeoutToast)
const errorTrends = await handleDslRequest(http, latencyTrendDSL, getJaegerErrorTrendQuery(), mode, setShowTimeoutToast)
.then((response) => {
const map: any = {};
response.aggregations.trace_group_name.buckets.map((bucket) => {
Expand Down Expand Up @@ -304,7 +304,7 @@ export const handleJaegerErrorDashboardRequest = async (
})
.catch((error) => console.error(error));

await handleDslRequest(http, DSL, getJaegerErrorDashboardQuery(), mode, true, setShowTimeoutToast)
await handleDslRequest(http, DSL, getJaegerErrorDashboardQuery(), mode, setShowTimeoutToast)
.then((response) => {
return Promise.all(
response.aggregations.trace_group_name.buckets.map((bucket) => {
Expand Down
20 changes: 10 additions & 10 deletions public/components/trace_analytics/requests/request_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export async function handleDslRequest(
DSL: any,
bodyQuery: any,
mode: TraceAnalyticsMode,
timeout?: boolean,
setShowTimeoutToast?: () => void
) {
if (DSL?.query) {
Expand All @@ -33,8 +32,8 @@ export async function handleDslRequest(
if (!bodyQuery.index) {
body = { ...bodyQuery, index: mode === 'jaeger' ? JAEGER_INDEX_NAME : DATA_PREPPER_INDEX_NAME };
}
if (timeout) {
const id = setTimeout(() => setShowTimeoutToast!(), 25000); // 25 seconds
if (setShowTimeoutToast) {
const id = setTimeout(() => setShowTimeoutToast(), 25000); // 25 seconds

try {
return await http.post(TRACE_ANALYTICS_DSL_ROUTE, {
Expand All @@ -45,14 +44,15 @@ export async function handleDslRequest(
} finally {
clearTimeout(id);
}
}
} else {

try {
return await http.post(TRACE_ANALYTICS_DSL_ROUTE, {
body: JSON.stringify(body),
});
} catch (error_1) {
console.error(error_1);
try {
return await http.post(TRACE_ANALYTICS_DSL_ROUTE, {
body: JSON.stringify(body),
});
} catch (error_1) {
console.error(error_1);
}
}
}

Expand Down

0 comments on commit e9941e0

Please sign in to comment.