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] API integration tests for APM latency correlation. #104644

Merged

Conversation

walterra
Copy link
Contributor

@walterra walterra commented Jul 7, 2021

Summary

Follow up to #99905.

Fixes #105049 (updated how we pass on APM's params to the async search service)

Adds API integration tests for APM Latency Correlations code.

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

  • If the applied filters don't return any docs, we won't throw an error anymore. Instead, the async search service finishes early and just returns no results.
  • If for whatever reason the async search service throws an error, it will also set its state now to isRunning = false.
  • If the client triggers a request with a service ID we now make sure that async search service still exists. We throw an error if that service no longer exists. This avoids re-instantiating async search services when they've already finished or failed and for whatever reason a client triggers another request with the same ID.
  • Refactored requests to reuse APM's own getCorrelationsFilters(). We now require start/end to be set and it will be converted from ISO (client side) to epochmillis (server side) to be more in line with APM's existing code.
  • The async search service now creates a simple internal log. This gets exposed via the API and we assert it using the API tests. In the future, we might also expose it in the UI to allow for better problem investigation for users and support.

Checklist

@walterra walterra self-assigned this Jul 7, 2021
@walterra walterra marked this pull request as ready for review July 7, 2021 13:10
@walterra walterra requested a review from a team as a code owner July 7, 2021 13:10
@walterra walterra added :ml apm:correlations Team:APM All issues that need APM UI Team support labels Jul 7, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

@elasticmachine
Copy link
Contributor

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

@walterra walterra added bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes v7.14.0 v7.15.0 v8.0.0 labels Jul 7, 2021
@walterra walterra requested a review from qn895 July 7, 2021 13:11
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.

Looks ok, but are the test failures related to the changes here? Is this ready for review or is there more work needed on making the tests pass?

if (resp.body.aggregations === undefined) {
throw new Error(
'fetchTransactionDurationHistogramInterval failed, did not return aggregations.'
'fetchTransactionDurationHistogramRangesteps failed, did not return aggregations.'
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it rangeSteps or rangesteps? The file name and function name and error messages don't agree.

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! I renamed everything to be consistent rangeSteps and range_steps in 509a02d.

@walterra
Copy link
Contributor Author

walterra commented Jul 8, 2021

@smith Thanks for the review, I thought it was ready but I overlooked that the bugs I fixed as part of this PR caused the existing unit tests to fail. Fixed those in 509a02d. Also identified an issue with how we applied filters which should now be fixed but needed changing the assertions for API tests. I'll flip this to draft again until all tests pass.

@walterra walterra marked this pull request as draft July 8, 2021 12:50
@walterra walterra marked this pull request as ready for review July 9, 2021 09:22
@walterra
Copy link
Contributor Author

walterra commented Jul 9, 2021

Tests passed, this is ready for another look! @smith @qn895

@qn895
Copy link
Member

qn895 commented Jul 9, 2021

Tested and LGTM 🎉

@walterra
Copy link
Contributor Author

I switched the dataset used for the tests from apm_8.0.0 to ml_8.0.0, this one is able to return an actual correlation based on the limited data.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
apm 4.3MB 4.3MB -4.0B

History

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

cc @walterra

@walterra walterra added the auto-backport Deprecated - use backport:version if exact versions are needed label Jul 12, 2021
@walterra walterra enabled auto-merge (squash) July 12, 2021 11:21
@walterra walterra mentioned this pull request Jul 13, 2021
15 tasks
@walterra walterra merged commit 5dc1c8f into elastic:master Jul 13, 2021
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 13, 2021
Adds API integration tests for APM Latency Correlations code.

Writing the tests surfaced some glitches fixed as part of this PR:
- If the applied filters don't return any docs, we won't throw an error anymore. Instead, the async search service finishes early and just returns no results.
- If for whatever reason the async search service throws an error, it will also set its state now to isRunning = false.
- If the client triggers a request with a service ID we now make sure that async search service still exists. We throw an error if that service no longer exists. This avoids re-instantiating async search services when they've already finished or failed and for whatever reason a client triggers another request with the same ID.
- Refactored requests to reuse APM's own getCorrelationsFilters(). We now require start/end to be set and it will be converted from ISO (client side) to epochmillis (server side) to be more in line with APM's existing code.
- The async search service now creates a simple internal log. This gets exposed via the API and we assert it using the API tests. In the future, we might also expose it in the UI to allow for better problem investigation for users and support.
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 13, 2021
Adds API integration tests for APM Latency Correlations code.

Writing the tests surfaced some glitches fixed as part of this PR:
- If the applied filters don't return any docs, we won't throw an error anymore. Instead, the async search service finishes early and just returns no results.
- If for whatever reason the async search service throws an error, it will also set its state now to isRunning = false.
- If the client triggers a request with a service ID we now make sure that async search service still exists. We throw an error if that service no longer exists. This avoids re-instantiating async search services when they've already finished or failed and for whatever reason a client triggers another request with the same ID.
- Refactored requests to reuse APM's own getCorrelationsFilters(). We now require start/end to be set and it will be converted from ISO (client side) to epochmillis (server side) to be more in line with APM's existing code.
- The async search service now creates a simple internal log. This gets exposed via the API and we assert it using the API tests. In the future, we might also expose it in the UI to allow for better problem investigation for users and support.
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.14
7.x

The backport PRs will be merged automatically after passing CI.

@walterra walterra deleted the ml-apm-correlations-api-integration-tests branch July 15, 2021 08:26
walterra added a commit that referenced this pull request Jul 15, 2021
…) (#105606)

Adds API integration tests for APM Latency Correlations code.

Writing the tests surfaced some glitches fixed as part of this PR:
- If the applied filters don't return any docs, we won't throw an error anymore. Instead, the async search service finishes early and just returns no results.
- If for whatever reason the async search service throws an error, it will also set its state now to isRunning = false.
- If the client triggers a request with a service ID we now make sure that async search service still exists. We throw an error if that service no longer exists. This avoids re-instantiating async search services when they've already finished or failed and for whatever reason a client triggers another request with the same ID.
- Refactored requests to reuse APM's own getCorrelationsFilters(). We now require start/end to be set and it will be converted from ISO (client side) to epochmillis (server side) to be more in line with APM's existing code.
- The async search service now creates a simple internal log. This gets exposed via the API and we assert it using the API tests. In the future, we might also expose it in the UI to allow for better problem investigation for users and support.
- Use 8.0.0 dataset instead of ml_8.0.0
walterra added a commit that referenced this pull request Jul 15, 2021
… (#105719)

Adds API integration tests for APM Latency Correlations code.

Writing the tests surfaced some glitches fixed as part of this PR:
- If the applied filters don't return any docs, we won't throw an error anymore. Instead, the async search service finishes early and just returns no results.
- If for whatever reason the async search service throws an error, it will also set its state now to isRunning = false.
- If the client triggers a request with a service ID we now make sure that async search service still exists. We throw an error if that service no longer exists. This avoids re-instantiating async search services when they've already finished or failed and for whatever reason a client triggers another request with the same ID.
- Refactored requests to reuse APM's own getCorrelationsFilters(). We now require start/end to be set and it will be converted from ISO (client side) to epochmillis (server side) to be more in line with APM's existing code.
- The async search service now creates a simple internal log. This gets exposed via the API and we assert it using the API tests. In the future, we might also expose it in the UI to allow for better problem investigation for users and support.
- Use 8.0.0 dataset instead of ml_8.0.0
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.

[APM] Latency correlations: Do not include comparison date range
5 participants