-
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
Make data.search.aggs available on the server. #74472
Conversation
2652342
to
196eb1d
Compare
Pinging @elastic/kibana-app-arch (Team:AppArch) |
* default timezone, but `isDefault` is not currently offered on the | ||
* server, so we need to manually check for the default value. | ||
*/ | ||
isDefaultTimezone: () => getConfig('dateFormat:tz') === 'Browser', |
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.
Ideally we'd add isDefault
to the uiSettings
service on the server so that we don't need to manually check against the default value. I'm looking into this as an alternative.
buckets: defaultAggTypes.buckets.concat(cachedAggTypes.buckets), | ||
metrics: defaultAggTypes.metrics.concat(cachedAggTypes.metrics), |
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 need the default agg types which are in the registry to have ui settings which are scoped to the current user. However, technically 3rd party plugins can register their own agg types.
So for now we are making the assumption that 3rd party agg types are not using ui settings and therefore don't require a scoped saved objects client. This means we can store one shared copy of them in setup
, and then merge everything together here.
I think this is fine for now since we don't even have known 3rd party plugins registering custom agg types right now, and they'd need to be doing it from the server anyway.
Longer term we should consider revisiting the design of the agg types and perhaps simplify things so that we could do something like give each agg type its own getConfig
as a convenience, which could be used inside of the agg. But this would likely require a simpler "definition" style of registry item, similar to what we've done elsewhere (like expressions).
|
||
public start({ fieldFormats, uiSettings }: AggsStartDependencies): AggsStart { | ||
return { | ||
asScopedToClient: async (savedObjectsClient: SavedObjectsClientContract) => { |
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.
Named asScopedToClient
since it is consistent with core.uiSettings.asScopedToClient
@elasticmachine merge upstream |
@elasticmachine merge upstream |
1 similar comment
@elasticmachine merge upstream |
299ee24
to
0a1bea9
Compare
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.
code LGTM
0a1bea9
to
5f5e4d1
Compare
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.
Code LGTM - focused on the changed lens test. Tested locally in Chrome, searching for regressions in lens and the visualize editor, and everything looks good.
💚 Build SucceededBuild metrics@kbn/optimizer bundle module count
page load bundle size
History
To update your PR or re-run it, just comment with: |
* master: (23 commits) Adding API test for custom link transaction example (elastic#74238) [Uptime] Singular alert (elastic#74659) Revert "attempt excluding a codeowners directory" (elastic#75023) [Metrics UI] Remove TSVB dependency from Metrics Explorer APIs (elastic#74804) Remove degraded state from ES status service (elastic#75007) [Reporting/Functional] unskip pagination test (elastic#74973) [Resolver] Stale query string values are removed when resolver's component instance ID changes. (elastic#74979) Add public url to Workplace Search plugin (elastic#74991) [Reporting] Update more Server Types for TaskManager (elastic#74915) [I18n] verify select icu-message options are in english (elastic#74963) Make data.search.aggs available on the server. (elastic#74472) [Security Solution][Resolver] Graph Control Tests and Update Simulator Selectors (elastic#74680) attempt excluding a codeowners directory [ML] DF Analytics: allow failed job to be stopped by force via the UI (elastic#74710) Add kibana-core-ui-designers team (elastic#74970) [Metrics UI] Fix inventory footer misalignment (elastic#74707) Remove legacy optimizer (elastic#73154) Update design-specific GH code-owners (elastic#74877) skip test Reporting paginates content elastic#74922 [Metrics UI] Add Jest tests for alert previews (elastic#74890) ...
Closes #65793
Summary
This PR is the final step to expose the
aggs
service on the server. At a high level, it does the following:common
to be made available on client & server.core.uiSettings
a bit differently, and need to write some glue code to pass the correct dependencies to the common service.calculateAutoTimeExpression
fromsetup
method and only provides it duringstart
setup
, and since it takesuiSettings
as a dependency it wasn't really possible to expose it on the server duringsetup
. So I removed it to keep the setup/start contracts the same across client and server.It's not (quite) as scary as it looks.
This is a big PR, but not as intimidating as it looks: Since we are adding a new service on the server, about 46 markdown files were automatically generated. Additionally, the majority of files touched here were simply moved without changes, or moved while only updating import paths.
Reviewers
I tried to keep a clean commit history in hopes it would make reviews easier, but another way to approach this would be to start with reviewing the 3 different
aggs_service.ts
files (in common, public, and server), and then moving forward from there.Testing
Initially the server API that is introduced here is not being used elsewhere in Kibana, so the main thing to test for would be any regressions in the browser around aggs -- these would be most likely to surface in core visualizations or lens, which are using this service behind the scenes.
Specific agg types to test which are slightly more complex in terms of dependencies and therefore more likely to break: percentile ranks, date histogram, histogram, range, date range.
Dev docs
The
search.aggs
service in thedata
plugin is now available on the server. Usage is the same as on the client, except that a scoped saved objects client must be provided on the server in order to retrieve thestart
contract:As part of this change, the
calculateAutoTimeExpression
method was removed from thesetup
contract, and now only exists on thedata
plugin'sstart
contract. The method was unused insetup
elsewhere in Kibana, so it was removed for simplicity.In addition, the agg types registry has changed and now accepts a provider function which is used to inject dependencies which may be needed in the agg type definition, specifically a
getConfig
function which can be used to retrieve uiSettings:We expect more changes to the agg type definition over the next few minor releases, and will add release notes indicating any future updates.