Skip to content

Commit

Permalink
Don’t remove first bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenlouv committed Apr 2, 2019
1 parent 97e7729 commit 2fd0960
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Object {
"overallAvgDuration": 32861.15660262639,
"responseTimes": Object {
"avg": Array [
Object {
"x": 1528113600000,
"y": 26310.63483891513,
},
Object {
"x": 1528124400000,
"y": 26193.277795595466,
Expand Down Expand Up @@ -327,6 +331,10 @@ Object {
},
],
"p95": Array [
Object {
"x": 1528113600000,
"y": 82172.85648714812,
},
Object {
"x": 1528124400000,
"y": 80738.78571428556,
Expand Down Expand Up @@ -649,6 +657,10 @@ Object {
},
],
"p99": Array [
Object {
"x": 1528113600000,
"y": 293866.3866666665,
},
Object {
"x": 1528124400000,
"y": 293257.27333333343,
Expand Down Expand Up @@ -975,6 +987,10 @@ Object {
"tpmBuckets": Array [
Object {
"dataPoints": Array [
Object {
"x": 1528113600000,
"y": 82230,
},
Object {
"x": 1528124400000,
"y": 81460,
Expand Down Expand Up @@ -1300,6 +1316,10 @@ Object {
},
Object {
"dataPoints": Array [
Object {
"x": 1528113600000,
"y": 0,
},
Object {
"x": 1528124400000,
"y": 0,
Expand Down Expand Up @@ -1625,6 +1645,10 @@ Object {
},
Object {
"dataPoints": Array [
Object {
"x": 1528113600000,
"y": 5930,
},
Object {
"x": 1528124400000,
"y": 6065,
Expand Down Expand Up @@ -1950,6 +1974,10 @@ Object {
},
Object {
"dataPoints": Array [
Object {
"x": 1528113600000,
"y": 6045,
},
Object {
"x": 1528124400000,
"y": 6015,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { first } from 'lodash';
import { timeseriesResponse } from './mock-responses/timeseries_response';
import {
ApmTimeSeriesResponse,
Expand All @@ -21,15 +20,6 @@ describe('timeseriesTransformer', () => {
});
});

it('should remove first bucket', () => {
const mockDates = timeseriesResponse.aggregations.transaction_results.buckets[0].timeseries.buckets.map(
bucket => bucket.key
);

expect(first(res.responseTimes.avg).x).not.toBe(first(mockDates));
expect(first(res.tpmBuckets[0].dataPoints).x).not.toBe(first(mockDates));
});

it('should have correct order', () => {
expect(res.tpmBuckets.map(bucket => bucket.key)).toEqual([
'HTTP 2xx',
Expand Down Expand Up @@ -108,11 +98,21 @@ describe('getTpmBuckets', () => {
const bucketSize = 10;
expect(getTpmBuckets(buckets, bucketSize)).toEqual([
{
dataPoints: [{ x: 1, y: 1200 }, { x: 2, y: 1800 }, { x: 3, y: 2400 }],
dataPoints: [
{ x: 0, y: 0 },
{ x: 1, y: 1200 },
{ x: 2, y: 1800 },
{ x: 3, y: 2400 }
],
key: 'HTTP 4xx'
},
{
dataPoints: [{ x: 1, y: 3000 }, { x: 2, y: 600 }, { x: 3, y: 1800 }],
dataPoints: [
{ x: 0, y: 0 },
{ x: 1, y: 3000 },
{ x: 2, y: 600 },
{ x: 3, y: 1800 }
],
key: 'HTTP 5xx'
}
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function getTpmBuckets(
) {
const buckets = transactionResultBuckets.map(
({ key: resultKey, timeseries }) => {
const dataPoints = timeseries.buckets.slice(1).map(bucket => {
const dataPoints = timeseries.buckets.map(bucket => {
return {
x: bucket.key,
y: round(bucket.doc_count * (60 / bucketSize), 1)
Expand All @@ -82,7 +82,7 @@ export function getTpmBuckets(
function getResponseTime(
responseTimeBuckets: ESResponse['aggregations']['response_times']['buckets'] = []
) {
return responseTimeBuckets.slice(1).reduce(
return responseTimeBuckets.reduce(
(acc, bucket) => {
const { '95.0': p95, '99.0': p99 } = bucket.pct.values;

Expand Down

0 comments on commit 2fd0960

Please sign in to comment.