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

Move to modified version of original status count for speed #41210

Merged
merged 8 commits into from
Jul 17, 2019

Conversation

andrewvc
Copy link
Contributor

@andrewvc andrewvc commented Jul 16, 2019

Summary

This attempts to speed up the now slow snapshot count @justinkambic noticed. It uses a different approach form #41203, it's actually a modified version of the old formula. It should be faster. It achieves this executing a query that's very friendly to composite aggs, even if it returns more data than strictly necessary.

This also fixes a bug in the original implementation, where the total would be equivalent to the filtered value, rather than the pre-filtered value. This made little sense since you'd just see the total twice.

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@andrewvc andrewvc added bug Fixes for quality problems that affect the customer experience review [zube]: In Review labels Jul 16, 2019
@andrewvc andrewvc self-assigned this Jul 16, 2019
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@andrewvc andrewvc added the release_note:skip Skip the PR/issue when compiling release notes label Jul 16, 2019
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@andrewvc andrewvc added the Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability label Jul 16, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/uptime

Copy link
Contributor

@justinkambic justinkambic left a comment

Choose a reason for hiding this comment

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

This functionality seems to work for me, and I like the improvement to the way we express total.

I'm looking for a little discussion on some of my comments but aside from that this looks great.

Thank you for tackling this important task.

let searchAfter: any = null;

const summaryByIdLocation: {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can probably extract a type for this and put it in the adjacent adapter_types file. A separate type for the location value would probably be cleaner too.

down++;
}
const source: any = get(bucket, 'latest.hits.hits[0]._source');
const {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these keys guaranteed to be defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, aggregations always return a value.

}
}

return result;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have a unit test for this function? It may be good to create a mock JSON result (from real-world query results) and a subsequent test snapshot to help ensure that future revisions don't break this function, since we're planning to make it GA and we've developed it so late.

If you agree then I'm happy to add this, or do it in a follow-up PR. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For this specific case I don't see a ton of value in the unit test. Our functional tests check this against real query results from an ES cluster. That said it'd be nice to have the unit test to make future development against this code easier, since running functional tests is a pain.

Copy link
Contributor

Choose a reason for hiding this comment

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

I might make more of a meta-style issue to try to address this. Once we've stabilized these backend functions it'll be important to ensure that future changes don't erode the functionality.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

++ to have a style discussion elsewhere. When/where to unit test is a complex question with no one single answer, and no shortage of different philosophies.

@@ -1,5 +1,5 @@
{
"snapshot": {
"counts": { "down": 2, "mixed": 0, "up": 0, "total": 2 }
"counts": { "down": 2, "mixed": 0, "up": 0, "total": 10 }
Copy link
Contributor

Choose a reason for hiding this comment

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

I like that we're doing this now. I think. 😺

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would categorize the previous behavior as a bug IMHO.

…ticsearch_monitors_adapter.ts

Co-Authored-By: Justin Kambic <justin.kambic@elastic.co>
@elasticmachine
Copy link
Contributor

💔 Build Failed

Copy link
Contributor

@justinkambic justinkambic left a comment

Choose a reason for hiding this comment

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

LGTM WFG

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@andrewvc andrewvc merged commit 9ecadb2 into elastic:master Jul 17, 2019
@andrewvc andrewvc deleted the fast-status-count branch July 17, 2019 00:09
@zube zube bot removed the [zube]: In Review label Jul 17, 2019
@zube zube bot added the [zube]: Done label Jul 17, 2019
andrewvc added a commit to andrewvc/kibana that referenced this pull request Jul 17, 2019
…41210)

This attempts to speed up the now slow snapshot count @justinkambic noticed. It uses a different approach form elastic#41203, it's actually a modified version of the old formula. It should be faster. It achieves this executing a query that's very friendly to composite aggs, even if it returns more data than strictly necessary.

This also fixes a bug in the original implementation, where the total would be equivalent to the filtered value, rather than the pre-filtered value. This made little sense since you'd just see the total twice.
andrewvc added a commit to andrewvc/kibana that referenced this pull request Jul 17, 2019
…41210)

This attempts to speed up the now slow snapshot count @justinkambic noticed. It uses a different approach form elastic#41203, it's actually a modified version of the old formula. It should be faster. It achieves this executing a query that's very friendly to composite aggs, even if it returns more data than strictly necessary.

This also fixes a bug in the original implementation, where the total would be equivalent to the filtered value, rather than the pre-filtered value. This made little sense since you'd just see the total twice.
andrewvc added a commit that referenced this pull request Jul 17, 2019
…41323)

This attempts to speed up the now slow snapshot count @justinkambic noticed. It uses a different approach form #41203, it's actually a modified version of the old formula. It should be faster. It achieves this executing a query that's very friendly to composite aggs, even if it returns more data than strictly necessary.

This also fixes a bug in the original implementation, where the total would be equivalent to the filtered value, rather than the pre-filtered value. This made little sense since you'd just see the total twice.
andrewvc added a commit that referenced this pull request Jul 17, 2019
…41325)

This attempts to speed up the now slow snapshot count @justinkambic noticed. It uses a different approach form #41203, it's actually a modified version of the old formula. It should be faster. It achieves this executing a query that's very friendly to composite aggs, even if it returns more data than strictly necessary.

This also fixes a bug in the original implementation, where the total would be equivalent to the filtered value, rather than the pre-filtered value. This made little sense since you'd just see the total twice.
andrewvc added a commit to andrewvc/kibana that referenced this pull request Jul 17, 2019
Patching this function in elastic#41210 fixed performance but was missing this filter clause. We depend on only processing summary info. This fixes errors around missing destructured data where we expect summary fields to be present.
andrewvc added a commit to andrewvc/kibana that referenced this pull request Jul 17, 2019
Patching this function in elastic#41210 fixed performance but was missing this filter clause. We depend on only processing summary info. This fixes errors around missing destructured data where we expect summary fields to be present.
andrewvc added a commit that referenced this pull request Jul 18, 2019
Patching this function in #41210 fixed performance but was missing this filter clause. We depend on only processing summary info. This fixes errors around missing destructured data where we expect summary fields to be present.
andrewvc added a commit to andrewvc/kibana that referenced this pull request Jul 18, 2019
…1335)

Patching this function in elastic#41210 fixed performance but was missing this filter clause. We depend on only processing summary info. This fixes errors around missing destructured data where we expect summary fields to be present.
andrewvc added a commit to andrewvc/kibana that referenced this pull request Jul 18, 2019
…1335)

Patching this function in elastic#41210 fixed performance but was missing this filter clause. We depend on only processing summary info. This fixes errors around missing destructured data where we expect summary fields to be present.
andrewvc added a commit that referenced this pull request Jul 18, 2019
) (#41424)

* [Uptime] Handle `mode: all` in uptime snapshot calculation (#41335)

Patching this function in #41210 fixed performance but was missing this filter clause. We depend on only processing summary info. This fixes errors around missing destructured data where we expect summary fields to be present.

* Update snapshot to use heartbeat7.0.0 index for backport
andrewvc added a commit that referenced this pull request Jul 18, 2019
) (#41423)

* [Uptime] Handle `mode: all` in uptime snapshot calculation (#41335)

Patching this function in #41210 fixed performance but was missing this filter clause. We depend on only processing summary info. This fixes errors around missing destructured data where we expect summary fields to be present.

* Update snapshot to use heartbeat7.0.0 index for backport
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes review Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants