Skip to content

Commit

Permalink
showing service maps when filte by environment not defined (elastic#7…
Browse files Browse the repository at this point in the history
  • Loading branch information
cauemarcondes committed Sep 16, 2020
1 parent ee8bc62 commit 32fb9c6
Show file tree
Hide file tree
Showing 3 changed files with 160 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
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,162 @@ export default function serviceMapsApiTests({ getService }: FtrProviderContext)

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

it('returns service map elements filtering by environment not defined', async () => {
const start = encodeURIComponent('2020-06-28T10:24:46.055Z');
const end = encodeURIComponent('2020-06-29T10:24:46.055Z');
const environment = 'ENVIRONMENT_NOT_DEFINED';
const response = await supertest.get(
`/api/apm/service-map?start=${start}&end=${end}&environment=${environment}`
);
expect(response.status).to.be(200);
expectSnapshot(response.body).toMatchInline(`
Object {
"elements": Array [
Object {
"data": Object {
"id": "client~opbeans-node",
"source": "client",
"sourceData": Object {
"agent.name": "rum-js",
"id": "client",
"service.environment": "ENVIRONMENT_NOT_DEFINED",
"service.name": "client",
},
"target": "opbeans-node",
"targetData": Object {
"agent.name": "nodejs",
"id": "opbeans-node",
"service.environment": "ENVIRONMENT_NOT_DEFINED",
"service.name": "opbeans-node",
},
},
},
Object {
"data": Object {
"id": "opbeans-java~>postgresql",
"source": "opbeans-java",
"sourceData": Object {
"agent.name": "java",
"id": "opbeans-java",
"service.environment": "ENVIRONMENT_NOT_DEFINED",
"service.name": "opbeans-java",
},
"target": ">postgresql",
"targetData": Object {
"id": ">postgresql",
"label": "postgresql",
"span.destination.service.resource": "postgresql",
"span.subtype": "postgresql",
"span.type": "db",
},
},
},
Object {
"data": Object {
"id": "opbeans-node~>postgresql",
"source": "opbeans-node",
"sourceData": Object {
"agent.name": "nodejs",
"id": "opbeans-node",
"service.environment": "ENVIRONMENT_NOT_DEFINED",
"service.name": "opbeans-node",
},
"target": ">postgresql",
"targetData": Object {
"id": ">postgresql",
"label": "postgresql",
"span.destination.service.resource": "postgresql",
"span.subtype": "postgresql",
"span.type": "db",
},
},
},
Object {
"data": Object {
"id": "opbeans-node~>redis",
"source": "opbeans-node",
"sourceData": Object {
"agent.name": "nodejs",
"id": "opbeans-node",
"service.environment": "ENVIRONMENT_NOT_DEFINED",
"service.name": "opbeans-node",
},
"target": ">redis",
"targetData": Object {
"id": ">redis",
"label": "redis",
"span.destination.service.resource": "redis",
"span.subtype": "redis",
"span.type": "cache",
},
},
},
Object {
"data": Object {
"id": "opbeans-node~opbeans-java",
"source": "opbeans-node",
"sourceData": Object {
"agent.name": "nodejs",
"id": "opbeans-node",
"service.environment": "ENVIRONMENT_NOT_DEFINED",
"service.name": "opbeans-node",
},
"target": "opbeans-java",
"targetData": Object {
"agent.name": "java",
"id": "opbeans-java",
"service.environment": "ENVIRONMENT_NOT_DEFINED",
"service.name": "opbeans-java",
},
},
},
Object {
"data": Object {
"agent.name": "rum-js",
"id": "client",
"service.environment": "ENVIRONMENT_NOT_DEFINED",
"service.name": "client",
},
},
Object {
"data": Object {
"agent.name": "nodejs",
"id": "opbeans-node",
"service.environment": "ENVIRONMENT_NOT_DEFINED",
"service.name": "opbeans-node",
},
},
Object {
"data": Object {
"id": ">redis",
"label": "redis",
"span.destination.service.resource": "redis",
"span.subtype": "redis",
"span.type": "cache",
},
},
Object {
"data": Object {
"agent.name": "java",
"id": "opbeans-java",
"service.environment": "ENVIRONMENT_NOT_DEFINED",
"service.name": "opbeans-java",
},
},
Object {
"data": Object {
"id": ">postgresql",
"label": "postgresql",
"span.destination.service.resource": "postgresql",
"span.subtype": "postgresql",
"span.type": "db",
},
},
],
}
`);
});
});
});

Expand Down

0 comments on commit 32fb9c6

Please sign in to comment.