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] Remove rate aggregations #114187

Merged
merged 23 commits into from
Oct 14, 2021

Conversation

cauemarcondes
Copy link
Contributor

@cauemarcondes cauemarcondes commented Oct 6, 2021

closes #112240

  • Remove rate aggs and calculate throughput manually.
  • Add API tests across different APIs comparing throughput value

Screen Shot 2021-10-07 at 3 00 59 PM

Screen Shot 2021-10-07 at 3 02 40 PM

@cauemarcondes cauemarcondes added release_note:fix auto-backport Deprecated - use backport:version if exact versions are needed v7.16.0 labels Oct 6, 2021
@cauemarcondes cauemarcondes force-pushed the apm-removing-rate-aggs branch from 9509b60 to eb78ad5 Compare October 7, 2021 15:40
@cauemarcondes cauemarcondes marked this pull request as ready for review October 7, 2021 19:02
@cauemarcondes cauemarcondes requested review from a team as code owners October 7, 2021 19:02
@botelastic botelastic bot added Team:APM All issues that need APM UI Team support Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability labels Oct 7, 2021
Copy link
Contributor

@shahzad31 shahzad31 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uptime changes LGTM !!

});
expect(core.http.post).toHaveBeenCalledTimes(1);
expect(core.http.post).toHaveBeenCalledWith('/api/metrics/overview/top', {
body: JSON.stringify({
sourceId: 'default',
bucketSize,
bucketSize: intervalString,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having a hard time following why these changes are necessary for the logs and metrics fetchers. Could you please help me understand why we need both bucketSize and intervalString and why we switch around their meanings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the APM api I need both bucketSize and intervalString now, before we were using bucketSize as string, which is incorrect, based on the function we use to calculate the bucket size getBucketSize. Now the callback function receives both options, and for you is just a matter of using the intervalString which will have the same value as the old bucketSize.

Copy link
Member

@weltenwort weltenwort Oct 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, but as implementers of the a data fetcher it would be good to know what these parameters mean. Are they redundant so we can choose which to use? Probably not, because then we wouldn't need both. But which to use when?

Maybe we could add that info to the parameter type definition?

Copy link
Contributor Author

@cauemarcondes cauemarcondes Oct 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are not redundant, although they will have the bucket as string and the bucket as number (seconds) for example if intervalString is 60s buckeSize will be 60.

But which to use when?

You'll use intervalString on DateHistogram aggregation, and buckeSize if you want to calculate the rate of a bucket.

Maybe we could add that info to the parameter type definition?

I'll add a description there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the explanation!

@cauemarcondes cauemarcondes enabled auto-merge (squash) October 13, 2021 18:52
Comment on lines +177 to +178
const throughputResponse = await callApi({ query: { environment: 'production' } });
throughput = throughputResponse.body;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why callApi doesn't return body?

Suggested change
const throughputResponse = await callApi({ query: { environment: 'production' } });
throughput = throughputResponse.body;
throughput = await callApi({ query: { environment: 'production' } });

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +266 to +271
const previousPeriodMean = meanBy(
throughputResponse.previousPeriod.filter(
(item) => isFiniteNumber(item.y) && item.y > 0
),
'y'
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to filter values out?

Suggested change
const previousPeriodMean = meanBy(
throughputResponse.previousPeriod.filter(
(item) => isFiniteNumber(item.y) && item.y > 0
),
'y'
);
const previousPeriodMean = meanBy(throughputResponse.previousPeriod, 'y');

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I don't filter values out I won't be able to compare it with the RATE variables, monthly because the interval used in the dateHistogram to fetch the comparisons is 1s and since we generated data every 1m it means that for every bucket that containes value we'll have 59 others with 0. That's why I though of filtering to only return what has value and get the mean of that.

@cauemarcondes
Copy link
Contributor Author

@elasticmachine merge upstream

Comment on lines 30 to 33
// Size of the bucket in seconds calculated based on a time range. e.g. 60
bucketSize: number;
// String representing the interval in seconds that is calculated based on a time range. e.g. '60s'
intervalString: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description for the two should be identical and just highlight the the type is different:

Suggested change
// Size of the bucket in seconds calculated based on a time range. e.g. 60
bucketSize: number;
// String representing the interval in seconds that is calculated based on a time range. e.g. '60s'
intervalString: string;
// Bucket size in seconds (number)
bucketSize: number;
// Bucket size in seconds (string)
intervalString: string;

Ideally the two was called the same even:

Suggested change
// Size of the bucket in seconds calculated based on a time range. e.g. 60
bucketSize: number;
// String representing the interval in seconds that is calculated based on a time range. e.g. '60s'
intervalString: string;
// Bucket size in seconds (number)
bucketSize: number;
// Bucket size in seconds (string)
bucketSizeString: string;

(but that is a larger refactor and probably not worth doing right now)

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
observability 257 258 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
apm 2.7MB 2.7MB -391.0B
observability 363.1KB 363.1KB -70.0B
uptime 564.7KB 564.7KB +4.0B
total -457.0B

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
apm 37 36 -1

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
infra 90.2KB 90.2KB +8.0B
Unknown metric groups

API count

id before after diff
observability 258 259 +1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Member

@weltenwort weltenwort left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

infra changes LGTM and they seems to be producing the same results

thank you!

@cauemarcondes cauemarcondes merged commit d7e7dbf into elastic:master Oct 14, 2021
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Oct 14, 2021
* fixing throughput chart api

* change backends

* adding intervalString to the observability callback functions

* fixing transaction group detailed stats

* fixing tests

* fixing test

* fixing obs tests

* fixing tests

* adding tests

* fixing ci

* using data generator

* changing name

* fixing i18n

* updating opbs test to use data generator

* fixing api tests

* fixing tests

* using data generator to run the tests

* fixing tests

* fixing test
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

@cauemarcondes cauemarcondes deleted the apm-removing-rate-aggs branch October 14, 2021 20:51
kibanamachine added a commit that referenced this pull request Oct 14, 2021
* fixing throughput chart api

* change backends

* adding intervalString to the observability callback functions

* fixing transaction group detailed stats

* fixing tests

* fixing test

* fixing obs tests

* fixing tests

* adding tests

* fixing ci

* using data generator

* changing name

* fixing i18n

* updating opbs test to use data generator

* fixing api tests

* fixing tests

* using data generator to run the tests

* fixing tests

* fixing test

Co-authored-by: Cauê Marcondes <[email protected]>
@cauemarcondes cauemarcondes restored the apm-removing-rate-aggs branch November 8, 2021 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed release_note:fix Team:APM All issues that need APM UI Team support Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability v7.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[APM] Metrics-Powered throughput is incorrect
7 participants