Skip to content

Commit

Permalink
[APM] fixes incorrect values in service overview throughput chart (#8…
Browse files Browse the repository at this point in the history
…9348)

* [APM] fixes incorrect values in service overview throughput chart
  • Loading branch information
ogupte committed Jan 29, 2021
1 parent 7465976 commit 8e57b63
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 32 deletions.
11 changes: 8 additions & 3 deletions x-pack/plugins/apm/server/lib/services/get_throughput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ interface Options {

type ESResponse = PromiseReturnType<typeof fetcher>;

function transform(response: ESResponse) {
function transform(response: ESResponse, options: Options) {
const { end, start } = options.setup;
const deltaAsMinutes = (end - start) / 1000 / 60;
if (response.hits.total.value === 0) {
return [];
}
const buckets = response.aggregations?.throughput.buckets ?? [];
return buckets.map(({ key: x, doc_count: y }) => ({ x, y }));
return buckets.map(({ key: x, doc_count: y }) => ({
x,
y: y / deltaAsMinutes,
}));
}

async function fetcher({
Expand Down Expand Up @@ -82,6 +87,6 @@ async function fetcher({

export async function getThroughput(options: Options) {
return {
throughput: transform(await fetcher(options)),
throughput: transform(await fetcher(options), options),
};
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8e57b63

Please sign in to comment.