Skip to content

Commit

Permalink
[APM] Service Map: Not Defined option doesn't work properly (elasti…
Browse files Browse the repository at this point in the history
…c#77757)

* Service Map:  option doesn't work properly

* addressing PR comment

* addressing PR comment

* adding unit tests

* addressing PR comment

* fixing tests

* addressing PR comment

* addressing PR comment

* addressing PR comment

* addressing PR comment

* addressing PR comment

* add filter by environment

* addressing PR comment

* fixing API tests

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
cauemarcondes and elasticmachine committed Oct 1, 2020
1 parent fa7ca30 commit f1be880
Show file tree
Hide file tree
Showing 24 changed files with 19,895 additions and 4,911 deletions.

This file was deleted.

23 changes: 15 additions & 8 deletions x-pack/plugins/apm/server/lib/service_map/get_service_map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { getServicesProjection } from '../../projections/services';
import { mergeProjection } from '../../projections/util/merge_projection';
import { PromiseReturnType } from '../../../typings/common';
import { Setup, SetupTimeRange } from '../helpers/setup_request';
import { getEnvironmentUiFilterES } from '../helpers/convert_ui_filters/get_environment_ui_filter_es';
import { transformServiceMapResponses } from './transform_service_map_responses';
import { getServiceMapFromTraceIds } from './get_service_map_from_trace_ids';
import { getTraceSampleIds } from './get_trace_sample_ids';
Expand Down Expand Up @@ -85,21 +86,27 @@ async function getServicesData(options: IEnvOptions) {
searchAggregatedTransactions,
});

const { filter } = projection.body.query.bool;
let { filter } = projection.body.query.bool;

if (options.serviceName) {
filter = filter.concat({
term: {
[SERVICE_NAME]: options.serviceName,
},
});
}

if (options.environment) {
filter = filter.concat(getEnvironmentUiFilterES(options.environment));
}

const params = mergeProjection(projection, {
body: {
size: 0,
query: {
bool: {
...projection.body.query.bool,
filter: options.serviceName
? filter.concat({
term: {
[SERVICE_NAME]: options.serviceName,
},
})
: filter,
filter,
},
},
aggs: {
Expand Down
Loading

0 comments on commit f1be880

Please sign in to comment.