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

[ML] Fractions API fix and jest unit tests for APM Latency Correlations. #103907

Merged
merged 8 commits into from
Jul 5, 2021

Conversation

walterra
Copy link
Contributor

@walterra walterra commented Jun 30, 2021

Summary

Follow up to #99905.

Adds jest unit tests for APM Latency Correlations code.

Writing the tests surfaced some minor glitches fixed as part of this PR:

  • Fixes a typo in the name for the fetchTransactionDurationPercentiles() function.
  • Avoids adding a @timestamp filter if neither start/end are set as parameters for getQueryWithParams().
  • Adds a check to only push to ranges arrays if it's length is already greater than 0.
  • Makes the check against from more strict otherwise it wouldn't be added as an attribute if 0.
  • Fixes progress calculation for field/value pair fetching.
  • Removes leading 0 from fractions since [ML] ensure the fractions and bucket doc count have the same lengths in bucket_count_ks_test elasticsearch#74624 got merged.
  • Removes deprecated use of track_total_hits.

Checklist

@walterra walterra added Team:APM All issues that need APM UI Team support :ml v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.14.0 apm:correlations labels Jun 30, 2021
@walterra walterra self-assigned this Jun 30, 2021
@spalger spalger added v7.15.0 and removed v7.14.0 labels Jun 30, 2021
@walterra walterra mentioned this pull request Jul 1, 2021
15 tasks
@walterra walterra force-pushed the ml-apm-correlations-unit-tests branch from acb70ac to 2642aab Compare July 1, 2021 09:42
@walterra walterra marked this pull request as ready for review July 1, 2021 09:43
@walterra walterra requested a review from a team as a code owner July 1, 2021 09:43
@walterra walterra requested a review from qn895 July 1, 2021 09:44
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:apm)

},
},
size: 1000,
track_total_hits: true,
Copy link
Member

@qn895 qn895 Jul 1, 2021

Choose a reason for hiding this comment

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

Looking at this again, I think we can remove this track_total_hits completely because we now use the totalDocCount from fetchTransactionDurationFractions for the histograms instead. This is something I should have removed in the last PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, removed it in f42dda2.

| undefined;

// fetchTransactionDurationPercentiles
if (req?.body?.aggs?.transaction_duration_percentiles !== undefined) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: can we do an assertion for req?.body?.aggs? before these if statements so we don't have to duplicate these checks again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored in 16ef560.

@qn895
Copy link
Member

qn895 commented Jul 1, 2021

Thanks for adding the unit tests. Changes LGTM 🎉 , just left a few minor comments.

Copy link
Contributor

@smith smith left a comment

Choose a reason for hiding this comment

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

Thanks for adding these. We usually don't add () in descriptions when describing functions so you can take those out if you like.

import { getQueryWithParams } from './get_query_with_params';

describe('correlations', () => {
describe('getQueryWithParams()', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
describe('getQueryWithParams()', () => {
describe('getQueryWithParams', () => {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, updated in 02a1fd2.

);
});

it('performs a client search with params when no ID is provided', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I usually break these up if there's a when in there:

Suggested change
it('performs a client search with params when no ID is provided', async () => {
describe('when no ID is provided', () => {
it('performs a client search with params', async () => {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in 44d5cc5.

@walterra walterra added the auto-backport Deprecated - use backport:version if exact versions are needed label Jul 5, 2021
@walterra walterra enabled auto-merge (squash) July 5, 2021 12:52
@walterra walterra added the bug Fixes for quality problems that affect the customer experience label Jul 5, 2021
@walterra walterra changed the title [ML] Jest unit tests for APM Latency Correlations. [ML] Bug fixes and jest unit tests for APM Latency Correlations. Jul 5, 2021
@walterra walterra changed the title [ML] Bug fixes and jest unit tests for APM Latency Correlations. [ML] Fractions API fix and jest unit tests for APM Latency Correlations. Jul 5, 2021
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

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

cc @walterra

@walterra walterra merged commit 2a37ef8 into elastic:master Jul 5, 2021
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 5, 2021
Adds jest unit tests for APM Latency Correlations code.

Writing the tests surfaced some minor glitches fixed as part of this PR:
- Fixes a typo in the name for the fetchTransactionDurationPercentiles() function.
- Avoids adding a @timestamp filter if neither start/end are set as parameters for getQueryWithParams().
- Adds a check to only push to ranges arrays if it's length is already greater than 0.
- Makes the check against from more strict otherwise it wouldn't be added as an attribute if 0.
- Fixes progress calculation for field/value pair fetching.
- Removes leading 0 from fractions since an ES update got merged.
- Removes deprecated use of track_total_hits.
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 5, 2021
Adds jest unit tests for APM Latency Correlations code.

Writing the tests surfaced some minor glitches fixed as part of this PR:
- Fixes a typo in the name for the fetchTransactionDurationPercentiles() function.
- Avoids adding a @timestamp filter if neither start/end are set as parameters for getQueryWithParams().
- Adds a check to only push to ranges arrays if it's length is already greater than 0.
- Makes the check against from more strict otherwise it wouldn't be added as an attribute if 0.
- Fixes progress calculation for field/value pair fetching.
- Removes leading 0 from fractions since an ES update got merged.
- Removes deprecated use of track_total_hits.
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.14
7.x

The backport PRs will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Jul 5, 2021
Adds jest unit tests for APM Latency Correlations code.

Writing the tests surfaced some minor glitches fixed as part of this PR:
- Fixes a typo in the name for the fetchTransactionDurationPercentiles() function.
- Avoids adding a @timestamp filter if neither start/end are set as parameters for getQueryWithParams().
- Adds a check to only push to ranges arrays if it's length is already greater than 0.
- Makes the check against from more strict otherwise it wouldn't be added as an attribute if 0.
- Fixes progress calculation for field/value pair fetching.
- Removes leading 0 from fractions since an ES update got merged.
- Removes deprecated use of track_total_hits.

Co-authored-by: Walter Rafelsberger <walter@elastic.co>
kibanamachine added a commit that referenced this pull request Jul 5, 2021
Adds jest unit tests for APM Latency Correlations code.

Writing the tests surfaced some minor glitches fixed as part of this PR:
- Fixes a typo in the name for the fetchTransactionDurationPercentiles() function.
- Avoids adding a @timestamp filter if neither start/end are set as parameters for getQueryWithParams().
- Adds a check to only push to ranges arrays if it's length is already greater than 0.
- Makes the check against from more strict otherwise it wouldn't be added as an attribute if 0.
- Fixes progress calculation for field/value pair fetching.
- Removes leading 0 from fractions since an ES update got merged.
- Removes deprecated use of track_total_hits.

Co-authored-by: Walter Rafelsberger <walter@elastic.co>
@walterra walterra deleted the ml-apm-correlations-unit-tests branch July 6, 2021 07:16
madirey pushed a commit to madirey/kibana that referenced this pull request Jul 6, 2021
Adds jest unit tests for APM Latency Correlations code.

Writing the tests surfaced some minor glitches fixed as part of this PR:
- Fixes a typo in the name for the fetchTransactionDurationPercentiles() function.
- Avoids adding a @timestamp filter if neither start/end are set as parameters for getQueryWithParams().
- Adds a check to only push to ranges arrays if it's length is already greater than 0.
- Makes the check against from more strict otherwise it wouldn't be added as an attribute if 0.
- Fixes progress calculation for field/value pair fetching.
- Removes leading 0 from fractions since an ES update got merged.
- Removes deprecated use of track_total_hits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:correlations auto-backport Deprecated - use backport:version if exact versions are needed bug Fixes for quality problems that affect the customer experience :ml release_note:skip Skip the PR/issue when compiling release notes Team:APM All issues that need APM UI Team support v7.14.0 v7.15.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants