From b26051ded0788cbea5e0aa4108492f109599ab66 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 16 Jul 2021 15:41:10 -0400 Subject: [PATCH] [User Experience App] Fix ux app env filter (#105918) (#106001) Co-authored-by: Shahzad --- .../components/app/RumDashboard/RumHome.tsx | 4 +-- .../__snapshots__/queries.test.ts.snap | 24 ++------------ .../ui_filters/get_es_filter.test.ts | 31 +++++++++++++++++++ .../rum_client/ui_filters/get_es_filter.ts | 5 ++- 4 files changed, 40 insertions(+), 24 deletions(-) create mode 100644 x-pack/plugins/apm/server/lib/rum_client/ui_filters/get_es_filter.test.ts diff --git a/x-pack/plugins/apm/public/components/app/RumDashboard/RumHome.tsx b/x-pack/plugins/apm/public/components/app/RumDashboard/RumHome.tsx index 88d1823f05ccc..26a44180b837d 100644 --- a/x-pack/plugins/apm/public/components/app/RumDashboard/RumHome.tsx +++ b/x-pack/plugins/apm/public/components/app/RumDashboard/RumHome.tsx @@ -27,7 +27,7 @@ export function RumHome() { const { isSmall, isXXL } = useBreakPoints(); - const envStyle = isSmall ? {} : { maxWidth: 200 }; + const envStyle = isSmall ? {} : { maxWidth: 500 }; return ( @@ -59,7 +59,7 @@ export function RumHome() { function PageHeader() { const { isSmall } = useBreakPoints(); - const envStyle = isSmall ? {} : { maxWidth: 200 }; + const envStyle = isSmall ? {} : { maxWidth: 400 }; return (
diff --git a/x-pack/plugins/apm/server/lib/rum_client/__snapshots__/queries.test.ts.snap b/x-pack/plugins/apm/server/lib/rum_client/__snapshots__/queries.test.ts.snap index f939a9c39c63c..aab8025a7679e 100644 --- a/x-pack/plugins/apm/server/lib/rum_client/__snapshots__/queries.test.ts.snap +++ b/x-pack/plugins/apm/server/lib/rum_client/__snapshots__/queries.test.ts.snap @@ -64,13 +64,7 @@ Object { }, }, ], - "must_not": Array [ - Object { - "term": Object { - "service.environment": "staging", - }, - }, - ], + "must_not": Array [], }, }, "size": 0, @@ -512,13 +506,7 @@ Object { }, }, ], - "must_not": Array [ - Object { - "term": Object { - "service.environment": "staging", - }, - }, - ], + "must_not": Array [], }, }, "size": 0, @@ -566,13 +554,7 @@ Object { }, }, ], - "must_not": Array [ - Object { - "term": Object { - "service.environment": "staging", - }, - }, - ], + "must_not": Array [], }, }, "size": 0, diff --git a/x-pack/plugins/apm/server/lib/rum_client/ui_filters/get_es_filter.test.ts b/x-pack/plugins/apm/server/lib/rum_client/ui_filters/get_es_filter.test.ts new file mode 100644 index 0000000000000..ba5e318a1901b --- /dev/null +++ b/x-pack/plugins/apm/server/lib/rum_client/ui_filters/get_es_filter.test.ts @@ -0,0 +1,31 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { getEsFilter } from './get_es_filter'; + +describe('getEfFilters', function () { + it('should return environment in include filters', function () { + const result = getEsFilter({ + browser: ['Chrome'], + environment: 'production', + }); + + expect(result).toEqual([ + { terms: { 'user_agent.name': ['Chrome'] } }, + { term: { 'service.environment': 'production' } }, + ]); + }); + + it('should not return environment in exclude filters', function () { + const result = getEsFilter( + { browserExcluded: ['Chrome'], environment: 'production' }, + true + ); + + expect(result).toEqual([{ terms: { 'user_agent.name': ['Chrome'] } }]); + }); +}); diff --git a/x-pack/plugins/apm/server/lib/rum_client/ui_filters/get_es_filter.ts b/x-pack/plugins/apm/server/lib/rum_client/ui_filters/get_es_filter.ts index 5f587f82e979d..76ef9fb95089f 100644 --- a/x-pack/plugins/apm/server/lib/rum_client/ui_filters/get_es_filter.ts +++ b/x-pack/plugins/apm/server/lib/rum_client/ui_filters/get_es_filter.ts @@ -34,5 +34,8 @@ export function getEsFilter(uiFilters: UxUIFilters, exclude?: boolean) { }; }) as ESFilter[]; - return [...mappedFilters, ...environmentQuery(uiFilters.environment)]; + return [ + ...mappedFilters, + ...(exclude ? [] : environmentQuery(uiFilters.environment)), + ]; }