A few more environment uiFilters fixes (#92044) (#92120)

Some places in the service map and annotations were still attempting to use environment from uiFilters. Fix these.

Co-authored-by: Nathan L Smith <nathan.smith@elastic.co>
This commit is contained in:
Kibana Machine 2021-02-20 22:35:29 -05:00 committed by GitHub
parent 83a59bc556
commit d9828c22d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 12 deletions

View file

@ -32,8 +32,7 @@ export function ServiceStatsFetcher({
serviceAnomalyStats,
}: ServiceStatsFetcherProps) {
const {
urlParams: { start, end },
uiFilters,
urlParams: { environment, start, end },
} = useUrlParams();
const {
@ -46,12 +45,12 @@ export function ServiceStatsFetcher({
endpoint: 'GET /api/apm/service-map/service/{serviceName}',
params: {
path: { serviceName },
query: { start, end, uiFilters: JSON.stringify(uiFilters) },
query: { environment, start, end },
},
});
}
},
[serviceName, start, end, uiFilters],
[environment, serviceName, start, end],
{
preservePreviousData: false,
}

View file

@ -23,9 +23,8 @@ export function AnnotationsContextProvider({
children: React.ReactNode;
}) {
const { serviceName } = useParams<{ serviceName?: string }>();
const { urlParams, uiFilters } = useUrlParams();
const { start, end } = urlParams;
const { environment } = uiFilters;
const { urlParams } = useUrlParams();
const { environment, start, end } = urlParams;
const { data = INITIAL_STATE } = useFetcher(
(callApmApi) => {

View file

@ -56,7 +56,7 @@ export function getServiceMapServiceNodeInfo({
searchAggregatedTransactions,
}: Options & { serviceName: string }) {
return withApmSpan('get_service_map_node_stats', async () => {
const { start, end, uiFilters } = setup;
const { start, end } = setup;
const filter: ESFilter[] = [
{ term: { [SERVICE_NAME]: serviceName } },
@ -66,7 +66,7 @@ export function getServiceMapServiceNodeInfo({
const minutes = Math.abs((end - start) / (1000 * 60));
const taskParams = {
environment: uiFilters.environment,
environment,
filter,
searchAggregatedTransactions,
minutes,

View file

@ -12,7 +12,7 @@ import { setupRequest } from '../lib/helpers/setup_request';
import { getServiceMap } from '../lib/service_map/get_service_map';
import { getServiceMapServiceNodeInfo } from '../lib/service_map/get_service_map_service_node_info';
import { createRoute } from './create_route';
import { environmentRt, rangeRt, uiFiltersRt } from './default_api_types';
import { environmentRt, rangeRt } from './default_api_types';
import { notifyFeatureUsage } from '../feature';
import { getSearchAggregatedTransactions } from '../lib/helpers/aggregated_transactions';
import { isActivePlatinumLicense } from '../../common/license_check';
@ -67,7 +67,7 @@ export const serviceMapServiceNodeRoute = createRoute({
path: t.type({
serviceName: t.string,
}),
query: t.intersection([rangeRt, uiFiltersRt]),
query: t.intersection([environmentRt, rangeRt]),
}),
options: { tags: ['access:apm'] },
handler: async ({ context, request }) => {
@ -81,6 +81,7 @@ export const serviceMapServiceNodeRoute = createRoute({
const {
path: { serviceName },
query: { environment },
} = context.params;
const searchAggregatedTransactions = await getSearchAggregatedTransactions(
@ -88,6 +89,7 @@ export const serviceMapServiceNodeRoute = createRoute({
);
return getServiceMapServiceNodeInfo({
environment,
setup,
serviceName,
searchAggregatedTransactions,

View file

@ -49,7 +49,6 @@ export default function serviceMapsApiTests({ getService }: FtrProviderContext)
const q = querystring.stringify({
start: metadata.start,
end: metadata.end,
uiFilters: encodeURIComponent('{}'),
});
const response = await supertest.get(`/api/apm/service-map/service/opbeans-node?${q}`);