-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Synthetics] Migrate service list query out of APM (#132548)
* Migrate service list query out of APM. * Delete obsolete e2e test. * Rename non-snakecase files. * Add tests for new filter generator. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
c0e2bc7
commit 1886f39
Showing
15 changed files
with
314 additions
and
165 deletions.
There are no files selected for viewing
47 changes: 0 additions & 47 deletions
47
x-pack/plugins/apm/server/routes/rum_client/__snapshots__/queries.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export enum ProcessorEvent { | ||
transaction = 'transaction', | ||
error = 'error', | ||
metric = 'metric', | ||
span = 'span', | ||
profile = 'profile', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* 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 { DeepPartial } from 'utility-types'; | ||
import { cloneDeep, isPlainObject, mergeWith } from 'lodash'; | ||
|
||
type PlainObject = Record<string | number | symbol, any>; | ||
|
||
type SourceProjection = DeepPartial<any>; | ||
|
||
type DeepMerge<T, U> = U extends PlainObject | ||
? T extends PlainObject | ||
? Omit<T, keyof U> & { | ||
[key in keyof U]: T extends { [k in key]: any } | ||
? DeepMerge<T[key], U[key]> | ||
: U[key]; | ||
} | ||
: U | ||
: U; | ||
|
||
export function mergeProjection<T extends any, U extends SourceProjection>( | ||
target: T, | ||
source: U | ||
): DeepMerge<T, U> { | ||
return mergeWith({}, cloneDeep(target), source, (a, b) => { | ||
if (isPlainObject(a) && isPlainObject(b)) { | ||
return undefined; | ||
} | ||
return b; | ||
}) as DeepMerge<T, U>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
x-pack/plugins/ux/public/services/data/__snapshots__/service_name_query.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
x-pack/plugins/ux/public/services/data/get_es_filter.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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('getEsFilters', 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'] } }]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* 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 { ESFilter } from '@kbn/core/types/elasticsearch'; | ||
import { ENVIRONMENT_ALL } from '../../../common/environment_filter_values'; | ||
import { | ||
uxLocalUIFilterNames, | ||
uxLocalUIFilters, | ||
} from '../../../common/ux_ui_filter'; | ||
import { UxUIFilters } from '../../../typings/ui_filters'; | ||
import { environmentQuery } from '../../components/app/rum_dashboard/local_uifilters/queries'; | ||
|
||
export function getEsFilter(uiFilters: UxUIFilters, exclude?: boolean) { | ||
const localFilterValues = uiFilters; | ||
const mappedFilters = uxLocalUIFilterNames | ||
.filter((name) => { | ||
const validFilter = name in localFilterValues; | ||
if (typeof name !== 'string') return false; | ||
if (exclude) { | ||
return name.includes('Excluded') && validFilter; | ||
} | ||
return !name.includes('Excluded') && validFilter; | ||
}) | ||
.map((filterName) => { | ||
const field = uxLocalUIFilters[filterName]; | ||
const value = localFilterValues[filterName]; | ||
|
||
return { | ||
terms: { | ||
[field.fieldName]: value, | ||
}, | ||
}; | ||
}) as ESFilter[]; | ||
|
||
return [ | ||
...mappedFilters, | ||
...(exclude | ||
? [] | ||
: environmentQuery(uiFilters.environment || ENVIRONMENT_ALL.value)), | ||
]; | ||
} |
Oops, something went wrong.