Skip to content

Commit

Permalink
adding request id
Browse files Browse the repository at this point in the history
  • Loading branch information
cauemarcondes committed Feb 18, 2021
1 parent 1ab4b0e commit 3b02302
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
import { i18n } from '@kbn/i18n';
import { orderBy } from 'lodash';
import React, { useState } from 'react';
import uuid from 'uuid';
import { useApmServiceContext } from '../../../../context/apm_service/use_apm_service_context';
import { useUrlParams } from '../../../../context/url_params_context/use_url_params';
import { FETCH_STATUS, useFetcher } from '../../../../hooks/use_fetcher';
Expand All @@ -37,6 +38,7 @@ const DEFAULT_SORT = {

const INITIAL_STATE = {
items: [],
requestId: undefined,
};

export function ServiceOverviewErrorsTable({ serviceName }: Props) {
Expand Down Expand Up @@ -78,14 +80,15 @@ export function ServiceOverviewErrorsTable({ serviceName }: Props) {
},
}).then((response) => {
return {
requestId: uuid(),
items: response.error_groups,
};
});
},
[environment, start, end, serviceName, uiFilters, transactionType]
);

const { items } = data;
const { requestId, items } = data;
const currentPageErrorGroups = orderBy(
items,
sort.field,
Expand All @@ -101,7 +104,7 @@ export function ServiceOverviewErrorsTable({ serviceName }: Props) {
} = useFetcher(
(callApmApi) => {
if (
status === FETCH_STATUS.SUCCESS &&
requestId &&
currentPageErrorGroups.length &&
start &&
end &&
Expand All @@ -124,9 +127,9 @@ export function ServiceOverviewErrorsTable({ serviceName }: Props) {
});
}
},
// only fetches agg results when status changes or group ids change
// only fetches agg results when requestId or group ids change
// eslint-disable-next-line react-hooks/exhaustive-deps
[status, groupIds],
[requestId, groupIds],
{ preservePreviousData: false }
);

Expand Down

0 comments on commit 3b02302

Please sign in to comment.