-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Use new es client in Uptime usage collector #86718
Use new es client in Uptime usage collector #86718
Conversation
@elasticmachine merge upstream |
Pinging @elastic/uptime (Team:uptime) |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
const savedObjectsClient = getSavedObjectsClient()!; | ||
if (savedObjectsClient) { | ||
await this.countNoOfUniqueMonitorAndLocations(callCluster, savedObjectsClient); | ||
await this.countNoOfUniqueMonitorAndLocations(esClient, savedObjectsClient); |
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.
await this.countNoOfUniqueMonitorAndLocations(esClient, savedObjectsClient); | |
const uptimeEsClient = createUptimeESClient({ esClient, savedObjectsClient }); | |
await this.countNoOfUniqueMonitorAndLocations(uptimeEsClient, savedObjectsClient); |
i think doing it like this will simplify things
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.
@shahzad31 The types for the SavedObjectsClient aren't the same in the collector and in createUptimeEsClient
. In the collector, savedObjectsClient
is of type ISavedObjectsRepository | undefined
, whereas createUptimeEsClient
expects savedObjectsClient
to be of type SavedObjectsClientContract
. We're missing errors
in the type that's being passed in.
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.
@shahzad31 we can get around this by changing the savedObjectsClient
type expected in createUptimeESClient
to be SavedObjectsClientContract | ISavedObjectsRepository
. Could you please take a look at the changes and approve or request changes if needed?
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.
@TinaHeiligers yeah i think that can work.
const { body: result } = isUptimeESClient(callCluster) | ||
? await callCluster.search(params) | ||
: await callCluster.search<ESSearchResponse<unknown, typeof params>>(params); |
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.
with your last commit i think, we can simplify this.
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.
@shahzad31 Great thinking, thank you for pointing that out!
I've replaced the conditional here
@@ -132,7 +130,7 @@ export class KibanaTelemetryAdapter { | |||
} | |||
|
|||
public static async countNoOfUniqueMonitorAndLocations( | |||
callCluster: ILegacyScopedClusterClient['callAsCurrentUser'] | UptimeESClient, | |||
callCluster: ElasticsearchClient | UptimeESClient, |
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 will now only be UptimeESClient
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.
@shahzad31 Thanks for catching that! Done
@shahzad31 Hopefully the third time reviewing this will be it. |
💚 Build SucceededMetrics [docs]Distributable file count
History
To update your PR or re-run it, just comment with: |
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 !!
Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Kibana Machine <[email protected]>
Summary
Refactors the
fetch
method in the uptime usage collector (KibanaTelemetryAdapter
) to use the new elasticsearch client rather than the deprecated legacy client.Part of #86358
Checklist
Delete any items that are not applicable to this PR.
For maintainers