Skip to content

Commit

Permalink
addressing PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cauemarcondes committed Feb 19, 2021
1 parent 3b02302 commit 9af5714
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 47 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/apm/server/routes/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ export const serviceErrorGroupsComparisonStatisticsRoute = createRoute({
t.type({
numBuckets: toNumberRt,
transactionType: t.string,
groupIds: t.string.pipe(jsonRt),
groupIds: jsonRt.pipe(t.array(t.string)),
}),
]),
}),
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/apm/server/routes/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const transactionGroupsComparisonStatisticsRoute = createRoute({
rangeRt,
uiFiltersRt,
t.type({
transactionNames: jsonRt,
transactionNames: jsonRt.pipe(t.array(t.string)),
numBuckets: toNumberRt,
transactionType: t.string,
latencyAggregationType: latencyAggregationTypeRt,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ export default function ApiTest({ getService }: FtrProviderContext) {
expect(response.status).to.be(200);

const errorGroupsComparisonStatistics = response.body as ErrorGroupsComparisonStatistics;
expect(Object.keys(errorGroupsComparisonStatistics).length).to.be.eql(groupIds.length);
expect(Object.keys(errorGroupsComparisonStatistics).sort()).to.eql(groupIds.sort());

groupIds.map((groupId) => {
groupIds.forEach((groupId) => {
expect(errorGroupsComparisonStatistics[groupId]).not.to.be.empty();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import expect from '@kbn/expect';
import archives_metadata from '../../common/fixtures/es_archiver/archives_metadata';
import { FtrProviderContext } from '../../common/ftr_provider_context';
import { registry } from '../../common/registry';
import { APIReturnType } from '../../../../plugins/apm/public/services/rest/createCallApmApi';

type ErrorGroupsPrimaryStatistics = APIReturnType<'GET /api/apm/services/{serviceName}/error_groups/primary_statistics'>;

export default function ApiTest({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
Expand Down Expand Up @@ -52,14 +55,60 @@ export default function ApiTest({ getService }: FtrProviderContext) {
const response = await supertest.get(
url.format({
pathname: `/api/apm/services/opbeans-java/error_groups/primary_statistics`,
query: { start, end, uiFilters: '{}', transactionType: 'request' },
query: {
start,
end,
uiFilters: '{}',
transactionType: 'request',
environment: 'production',
},
})
);

expect(response.status).to.be(200);
expect(response.body.is_aggregation_accurate).to.eql(true);
expect(response.body.error_groups.length).to.be.greaterThan(0);
expectSnapshot(response.body).toMatch();

const errorGroupPrimaryStatistics = response.body as ErrorGroupsPrimaryStatistics;

expect(errorGroupPrimaryStatistics.is_aggregation_accurate).to.eql(true);
expect(errorGroupPrimaryStatistics.error_groups.length).to.be.greaterThan(0);

expectSnapshot(errorGroupPrimaryStatistics.error_groups.map(({ name }) => name))
.toMatchInline(`
Array [
"Could not write JSON: Null return value from advice does not match primitive return type for: public abstract double co.elastic.apm.opbeans.repositories.Numbers.getRevenue(); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Null return value from advice does not match primitive return type for: public abstract double co.elastic.apm.opbeans.repositories.Numbers.getRevenue() (through reference chain: co.elastic.apm.opbeans.repositories.Stats[\\"numbers\\"]->com.sun.proxy.$Proxy132[\\"revenue\\"])",
"java.io.IOException: Connection reset by peer",
"java.io.IOException: Connection reset by peer",
"Could not write JSON: Unable to find co.elastic.apm.opbeans.model.Customer with id 7173; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Unable to find co.elastic.apm.opbeans.model.Customer with id 7173 (through reference chain: co.elastic.apm.opbeans.model.Customer_$$_jvst101_3[\\"email\\"])",
"Request method 'POST' not supported",
]
`);

const occurences = errorGroupPrimaryStatistics.error_groups.map(
({ occurrences }) => occurrences
);

occurences.forEach((occurence) => expect(occurence).to.be.greaterThan(0));

expectSnapshot(occurences).toMatchInline(`
Array [
5,
3,
2,
1,
1,
]
`);

const firstItem = errorGroupPrimaryStatistics.error_groups[0];

expectSnapshot(firstItem).toMatchInline(`
Object {
"group_id": "051f95eabf120ebe2f8b0399fe3e54c5",
"last_seen": 1607437366098,
"name": "Could not write JSON: Null return value from advice does not match primitive return type for: public abstract double co.elastic.apm.opbeans.repositories.Numbers.getRevenue(); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Null return value from advice does not match primitive return type for: public abstract double co.elastic.apm.opbeans.repositories.Numbers.getRevenue() (through reference chain: co.elastic.apm.opbeans.repositories.Stats[\\"numbers\\"]->com.sun.proxy.$Proxy132[\\"revenue\\"])",
"occurrences": 5,
}
`);
});
}
);
Expand Down

0 comments on commit 9af5714

Please sign in to comment.