forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] AIOps: Refactors function argument structure for Log Rate Analys…
…is. (elastic#187669) ## Summary Refactors the function argument structure of code used on Kibana server for Log Rate Analysis from individual arguments to single objects that contain all options. The options structure looks like this: ``` { // "meta" args like dependencies, general callbacks etc. on the outer most level esClient, abortSignal, ... // within "arguments" we pass in actual options that necessary for the logic of the function arguments: { start, end, query, fields, ... } } ``` The main benefit is that code where these functions are used become easier to read. Instead of the strict order of args that sometimes included `undefined` or just a value where it's hard to guess for which argument it's used for, this enforces to have the names of options show up in the consuming code. Here's an example: Before: ``` await fetchHistogramsForFields( client, requestBody.index, histogramQuery, [ { fieldName: requestBody.timeFieldName, type: KBN_FIELD_TYPES.DATE, interval: overallTimeSeries.interval, min: overallTimeSeries.stats[0], max: overallTimeSeries.stats[1], }, ], -1, undefined, abortSignal, stateHandler.sampleProbability(), RANDOM_SAMPLER_SEED ) ``` After: ``` (await fetchHistogramsForFields({ esClient, abortSignal, arguments: { indexPattern: requestBody.index, query: histogramQuery, fields: [ { fieldName: requestBody.timeFieldName, type: KBN_FIELD_TYPES.DATE, interval: overallTimeSeries.interval, min: overallTimeSeries.stats[0], max: overallTimeSeries.stats[1], }, ], samplerShardSize: -1, randomSamplerProbability: stateHandler.sampleProbability(), randomSamplerSeed: RANDOM_SAMPLER_SEED, }, })) as [NumericChartData] ``` ### Checklist - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- Loading branch information
Showing
20 changed files
with
375 additions
and
269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.