Skip to content

Commit

Permalink
[7.x] showing service maps when filte by environment not defined (#77483
Browse files Browse the repository at this point in the history
) | Fixing service maps API test (#77586) (#77603)

* showing service maps when filte by environment not defined (#77483)

* Fixing service maps API test (#77586)

* fixing api tests

* fixing api tests
# Conflicts:
#	x-pack/test/apm_api_integration/trial/tests/service_maps/service_maps.ts
  • Loading branch information
cauemarcondes authored Sep 16, 2020
1 parent 0a715bc commit cb7ba1f
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { find, uniqBy } from 'lodash';
import { ENVIRONMENT_NOT_DEFINED } from '../../../common/environment_filter_values';
import {
SERVICE_ENVIRONMENT,
SERVICE_NAME,
Expand Down Expand Up @@ -35,7 +36,7 @@ export function getConnections(
SERVICE_NAME in node &&
(node as ServiceConnectionNode)[SERVICE_NAME] === serviceName;
}
if (environment) {
if (environment && environment !== ENVIRONMENT_NOT_DEFINED.value) {
matches =
matches &&
SERVICE_ENVIRONMENT in node &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
TRACE_ID,
SPAN_DESTINATION_SERVICE_RESOURCE,
} from '../../../common/elasticsearch_fieldnames';
import { getEnvironmentUiFilterES } from '../helpers/convert_ui_filters/get_environment_ui_filter_es';

const MAX_TRACES_TO_INSPECT = 1000;

Expand Down Expand Up @@ -47,9 +48,7 @@ export async function getTraceSampleIds({
query.bool.filter.push({ term: { [SERVICE_NAME]: serviceName } });
}

if (environment) {
query.bool.filter.push({ term: { [SERVICE_ENVIRONMENT]: environment } });
}
query.bool.filter.push(...getEnvironmentUiFilterES(environment));

const fingerprintBucketSize = serviceName
? config['xpack.apm.serviceMapFingerprintBucketSize']
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,21 @@ export default function serviceMapsApiTests({ getService }: FtrProviderContext)

expectSnapshot(elements).toMatch();
});

it('returns service map elements filtering by environment not defined', async () => {
const ENVIRONMENT_NOT_DEFINED = 'ENVIRONMENT_NOT_DEFINED';
const { body, status } = await supertest.get(
`/api/apm/service-map?start=${start}&end=${end}&environment=${ENVIRONMENT_NOT_DEFINED}`
);
expect(status).to.be(200);
const environments = new Set();
body.elements.forEach((element: { data: Record<string, any> }) => {
environments.add(element.data['service.environment']);
});
expect(environments.size).to.eql(1);
expect(environments.has(ENVIRONMENT_NOT_DEFINED)).to.eql(true);
expectSnapshot(body).toMatch();
});
});
});

Expand Down

0 comments on commit cb7ba1f

Please sign in to comment.