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

Conform Search Profiler application organization to other ES UI plugins #82085

Merged
merged 7 commits into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion x-pack/plugins/searchprofiler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,30 @@
The search profiler consumes the [Profile API](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-profile.html)
by sending a `search` API with `profile: true` enabled in the request body. The response contains
detailed information on how Elasticsearch executed the search request. People use this information
to understand why a search request might be slow.
to understand why a search request might be slow.

## How to test

### Query profile

Execute the default query to generate results in the Query profile tab.

```json
{
"query":{
"match_all" : {}
}
}
```

### Aggregation profile

Execute an aggregation query to generate results in the Aggregation profile tab.

```json
{
"aggs": {
"avg_grade": { "avg": { "field": "grade" } }
}
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,22 @@ import {
EuiFlexItem,
EuiSpacer,
} from '@elastic/eui';
import { ProfileQueryEditor } from '../';

import {
SearchProfilerTabs,
ProfileTree,
HighlightDetailsFlyout,
LicenseWarningNotice,
} from '../../components';
ProfileLoadingPlaceholder,
EmptyTreePlaceHolder,
ProfileQueryEditor,
} from './components';

import { useAppContext } from '../../contexts/app_context';
import { useAppContext, useProfilerActionContext, useProfilerReadContext } from './contexts';
import { hasAggregations, hasSearch } from './utils';
import { Targets } from './types';

import { EmptyTreePlaceHolder, ProfileLoadingPlaceholder } from './components';
import { Targets } from '../../types';
import { useProfilerActionContext, useProfilerReadContext } from '../../contexts/profiler_context';

import { hasAggregations, hasSearch } from '../../utils';

export const Main = () => {
export const App = () => {
const { getLicenseStatus, notifications } = useAppContext();

const {
Expand Down
27 changes: 0 additions & 27 deletions x-pack/plugins/searchprofiler/public/application/boot.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { registerTestBed } from '../../../../../../../test_utils';
import { registerTestBed } from '../../../../../../test_utils';
import { EmptyTreePlaceHolder } from '.';

describe('EmptyTreePlaceholder', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* you may not use this file except in compliance with the Elastic License.
*/

export { Main } from './main';
export { EmptyTreePlaceHolder } from './empty_tree_placeholder';
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ export { SearchProfilerTabs } from './searchprofiler_tabs';
export { LicenseWarningNotice } from './license_warning_notice';
export { ProfileTree, OnHighlightChangeArgs } from './profile_tree';
export { HighlightDetailsFlyout } from './highlight_details_flyout';
export { ProfileLoadingPlaceholder } from './profile_loading_placeholder';
export { EmptyTreePlaceHolder } from './empty_tree_placeholder';
export { ProfileQueryEditor } from './profile_query_editor';
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
* you may not use this file except in compliance with the Elastic License.
*/

export { EmptyTreePlaceHolder } from './empty_tree_placeholder';
export { ProfileLoadingPlaceholder } from './profile_loading_placeholder';
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { registerTestBed } from '../../../../../../../test_utils';
import { registerTestBed } from '../../../../../../test_utils';
import { ProfileLoadingPlaceholder } from '.';

describe('Profile Loading Placeholder', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
* you may not use this file except in compliance with the Elastic License.
*/

export { Main } from './main';
export { ProfileQueryEditor } from './profile_query_editor';
export { useAppContext } from './app_context';
export { useProfilerActionContext, useProfilerReadContext } from './profiler_context';
34 changes: 27 additions & 7 deletions x-pack/plugins/searchprofiler/public/application/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,41 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import { Main } from './containers';
import { render, unmountComponentAtNode } from 'react-dom';
import { HttpStart as Http, ToastsSetup } from 'kibana/public';

import { LicenseStatus } from '../../common';
import { App } from './app';
import { AppContextProvider } from './contexts/app_context';
import { ProfileContextProvider } from './contexts/profiler_context';

import { AppDependencies } from './boot';
interface AppDependencies {
el: HTMLElement;
http: Http;
I18nContext: any;
notifications: ToastsSetup;
initialLicenseStatus: LicenseStatus;
}

export function App({ I18nContext, initialLicenseStatus, notifications, http }: AppDependencies) {
return (
export const renderApp = ({
el,
http,
I18nContext,
notifications,
initialLicenseStatus,
}: AppDependencies) => {
render(
<I18nContext>
<AppContextProvider args={{ initialLicenseStatus, notifications, http }}>
<ProfileContextProvider>
<Main />
<App />
</ProfileContextProvider>
</AppContextProvider>
</I18nContext>
</I18nContext>,
el
);
}

return () => unmountComponentAtNode(el);
};
4 changes: 2 additions & 2 deletions x-pack/plugins/searchprofiler/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ export class SearchProfilerUIPlugin implements Plugin<void, void, AppPublicPlugi
mount: async (params) => {
const [coreStart] = await getStartServices();
const { notifications, i18n: i18nDep } = coreStart;
const { boot } = await import('./application/boot');
const { renderApp } = await import('./application');

const license = await licensing.license$.pipe(first()).toPromise();
const initialLicenseStatus = checkLicenseStatus(license);

return boot({
return renderApp({
http,
initialLicenseStatus,
el: params.element,
Expand Down