Skip to content

Commit

Permalink
addressing pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cauemarcondes committed Dec 9, 2020
1 parent 345e261 commit f12bf04
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 610 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const theme = {

const latencyChartData = {
overallAvgDuration: 1,
latency: {
latencyTimeseries: {
avg: [{ x: 1, y: 10 }],
p95: [{ x: 2, y: 5 }],
p99: [{ x: 3, y: 8 }],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function getLatencyTimeseries({
theme: EuiTheme;
}) {
const { overallAvgDuration } = latencyChart;
const { avg, p95, p99 } = latencyChart.latency;
const { avg, p95, p99 } = latencyChart.latencyTimeseries;

const series = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const theme = {
} as EuiTheme;

const throughputData = {
throughput: [
throughputTimeseries: [
{ key: 'HTTP 2xx', avg: 1, dataPoints: [{ x: 1, y: 2 }] },
{ key: 'HTTP 4xx', avg: 1, dataPoints: [{ x: 1, y: 2 }] },
{ key: 'HTTP 5xx', avg: 1, dataPoints: [{ x: 1, y: 2 }] },
Expand Down
15 changes: 9 additions & 6 deletions x-pack/plugins/apm/public/selectors/throuput_chart_selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,20 @@ export function getThroughputTimeseries({
theme: EuiTheme;
throuputChart: ThrouputChartsResponse;
}) {
const bucketKeys = throuputChart.throughput.map(({ key }) => key);
const { throughputTimeseries } = throuputChart;
const bucketKeys = throughputTimeseries.map(({ key }) => key);
const getColor = getColorByKey(bucketKeys, theme);

const { throughput } = throuputChart;
if (!throughput.length) {
const start = throughput[0].dataPoints[0].x;
const end = throughput[0].dataPoints[throughput[0].dataPoints.length - 1].x;
if (!throughputTimeseries.length) {
const start = throughputTimeseries[0].dataPoints[0].x;
const end =
throughputTimeseries[0].dataPoints[
throughputTimeseries[0].dataPoints.length - 1
].x;
return getEmptySeries(start, end);
}

return throughput.map((bucket) => {
return throughputTimeseries.map((bucket) => {
return {
title: bucket.key,
data: bucket.dataPoints,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async function searchLatency({
size: 0,
query: { bool: { filter } },
aggs: {
latency: {
latencyTimeseries: {
date_histogram: {
field: '@timestamp',
fixed_interval: intervalString,
Expand All @@ -99,7 +99,7 @@ async function searchLatency({
return apmEventClient.search(params);
}

export async function getLatencyCharts({
export async function getLatencyTimeseries({
serviceName,
transactionType,
transactionName,
Expand All @@ -122,16 +122,16 @@ export async function getLatencyCharts({

if (!response.aggregations) {
return {
latency: { avg: [], p95: [], p99: [] },
latencyTimeseries: { avg: [], p95: [], p99: [] },
overallAvgDuration: null,
};
}

return {
overallAvgDuration:
response.aggregations.overall_avg_duration.value || null,
latency: convertLatencyBucketsToCoordinates(
response.aggregations.latency.buckets
latencyTimeseries: convertLatencyBucketsToCoordinates(
response.aggregations.latencyTimeseries.buckets
),
};
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { isNumber } from 'lodash';
import { LatencyChartsSearchResponse } from '.';
import { Coordinate } from '../../../../typings/timeseries';

type LatencyBuckets = Required<LatencyChartsSearchResponse>['aggregations']['latency']['buckets'];
type LatencyBuckets = Required<LatencyChartsSearchResponse>['aggregations']['latencyTimeseries']['buckets'];

export function convertLatencyBucketsToCoordinates(
latencyBuckets: LatencyBuckets = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export async function getThroughputCharts({
});

return {
throughput: getThroughputBuckets({
throughputTimeseries: getThroughputBuckets({
throughputResultBuckets: response.aggregations?.throughput.buckets,
bucketSize,
durationAsMinutes,
Expand Down
Loading

0 comments on commit f12bf04

Please sign in to comment.