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

[Search] Fix telemetry collection to not send extra requests #73382

Merged
merged 9 commits into from
Aug 3, 2020

Conversation

lukasolson
Copy link
Member

Summary

Fixes #73116.

This PR updates the usage collection for search to not send an additional request from the browser for each search request. Instead, we collect the telemetry from the server where we update the saved object that is used for telemetry.

@lukasolson lukasolson added review Feature:Search Querying infrastructure in Kibana Team:AppArch release_note:skip Skip the PR/issue when compiling release notes labels Jul 27, 2020
@lukasolson lukasolson requested a review from lizozom July 27, 2020 23:59
@lukasolson lukasolson requested a review from a team as a code owner July 27, 2020 23:59
@lukasolson lukasolson self-assigned this Jul 27, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-arch (Team:AppArch)

Copy link
Contributor

@lizozom lizozom left a comment

Choose a reason for hiding this comment

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

Multiple requests are not being sent anymore.
Lets just confirm that the data we do store is ok and usable.

@@ -71,7 +70,7 @@ export function usageProvider(core: CoreSetup<object, DataPluginStart>): SearchU
};

return {
trackError: getTracker('errorCount'),
trackError: () => getTracker('errorCount')(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the cide different for the error and the success handlers?

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't really have an accurate way to see the time a failure took since there is no took in the response for a failure. So this was just to make typescript happy since the error handler for errorCount didn't accept a duration.


const newAttributes = { ...attributes, averageDuration };
// Only track the average duration for successful requests
if (eventType === 'successCount') {
Copy link
Contributor

Choose a reason for hiding this comment

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

I actually think we should track the time to a failure too (an error status code or something for failures is important too)

@@ -30,9 +31,14 @@ export interface AsyncSearchResponse<T> {
response: SearchResponse<T>;
}

export function isAsyncSearchResponse<T>(response: any): response is AsyncSearchResponse<T> {
Copy link
Contributor

Choose a reason for hiding this comment

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

(a) instead of any you could use the response base class.
(b) no need to export this function as well as AsyncSearchResponse - it's not used (and shouldn't be used) externally.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 I'll give this a try

usage &&
(!isAsyncSearchResponse<any>(response) || (!response.is_partial && !response.is_running))
) {
usage.trackSuccess(response.rawResponse.took);
Copy link
Contributor

Choose a reason for hiding this comment

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

You also need to add an else clause with

if (response.is_partial && !response.is_running) {
    usage.trackError();
}

And adding some information to that failure would be great.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed, we'll have to add additional metadata in a subsequent PR but I cant add this error case.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

page load bundle size

id value diff baseline
data 1.4MB -1.2KB 1.4MB
dataEnhanced 177.9KB -120.0B 178.0KB
total - -1.3KB -

History

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

@lukasolson lukasolson merged commit 4758cb1 into elastic:master Aug 3, 2020
lukasolson added a commit to lukasolson/kibana that referenced this pull request Aug 3, 2020
…#73382)

* [Search] Fix telemetry collection to not send extra requests

* Update tracker to collect duration from ES response

* Fix type check

* Update docs and types

* Fix typescript

Co-authored-by: Liza K <liza.katz@elastic.co>
lukasolson added a commit to lukasolson/kibana that referenced this pull request Aug 3, 2020
…#73382)

* [Search] Fix telemetry collection to not send extra requests

* Update tracker to collect duration from ES response

* Fix type check

* Update docs and types

* Fix typescript

Co-authored-by: Liza K <liza.katz@elastic.co>
lukasolson added a commit that referenced this pull request Aug 3, 2020
…#74156)

* [Search] Fix telemetry collection to not send extra requests

* Update tracker to collect duration from ES response

* Fix type check

* Update docs and types

* Fix typescript

Co-authored-by: Liza K <liza.katz@elastic.co>

Co-authored-by: Liza K <liza.katz@elastic.co>
lukasolson added a commit that referenced this pull request Aug 3, 2020
…#74158)

* [Search] Fix telemetry collection to not send extra requests

* Update tracker to collect duration from ES response

* Fix type check

* Update docs and types

* Fix typescript

Co-authored-by: Liza K <liza.katz@elastic.co>

Co-authored-by: Liza K <liza.katz@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported Feature:Search Querying infrastructure in Kibana release_note:skip Skip the PR/issue when compiling release notes review v7.9.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Search] Telemetry makes too many requests
4 participants