Skip to content

Commit

Permalink
A few more environment uiFilters fixes (#92044) (#92120)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
kibanamachine and smith authored Feb 21, 2021
1 parent 83a59bc commit d9828c2
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ export function ServiceStatsFetcher({
serviceAnomalyStats,
}: ServiceStatsFetcherProps) {
const {
urlParams: { start, end },
uiFilters,
urlParams: { environment, start, end },
} = useUrlParams();

const {
Expand All @@ -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,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 } },
Expand All @@ -66,7 +66,7 @@ export function getServiceMapServiceNodeInfo({

const minutes = Math.abs((end - start) / (1000 * 60));
const taskParams = {
environment: uiFilters.environment,
environment,
filter,
searchAggregatedTransactions,
minutes,
Expand Down
6 changes: 4 additions & 2 deletions x-pack/plugins/apm/server/routes/service_map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 }) => {
Expand All @@ -81,13 +81,15 @@ export const serviceMapServiceNodeRoute = createRoute({

const {
path: { serviceName },
query: { environment },
} = context.params;

const searchAggregatedTransactions = await getSearchAggregatedTransactions(
setup
);

return getServiceMapServiceNodeInfo({
environment,
setup,
serviceName,
searchAggregatedTransactions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);

Expand Down

0 comments on commit d9828c2

Please sign in to comment.