Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APM] Service Map: Not Defined option doesn't work properly #77483

Merged
merged 1 commit into from
Sep 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
cauemarcondes marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -262,6 +262,162 @@ export default function serviceMapsApiTests({ getService }: FtrProviderContext)
}
`);
});

it('returns service map elements filtering by environment not defined', async () => {
const start = encodeURIComponent('2020-06-28T10:24:46.055Z');
cauemarcondes marked this conversation as resolved.
Show resolved Hide resolved
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(`
cauemarcondes marked this conversation as resolved.
Show resolved Hide resolved
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