-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Conversation
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
💔 Build Failed |
💚 Build Succeeded |
Pinging @elastic/uptime |
There was a problem hiding this 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: { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
x-pack/legacy/plugins/uptime/server/lib/adapters/monitors/elasticsearch_monitors_adapter.ts
Outdated
Show resolved
Hide resolved
x-pack/legacy/plugins/uptime/server/lib/adapters/monitors/elasticsearch_monitors_adapter.ts
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
return result; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 } |
There was a problem hiding this comment.
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. 😺
There was a problem hiding this comment.
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>
💔 Build Failed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM WFG
💚 Build Succeeded |
…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.
…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.
…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.
…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.
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.
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.
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.
…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.
…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.
) (#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
) (#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
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
strikethroughsto remove checklist items you don't feel are applicable to this PR.For maintainers