Skip to content

Commit

Permalink
Merge branch 'main' into 192166-dataset-quality-remove-datastreams-st…
Browse files Browse the repository at this point in the history
…ats-api-usage-on-serverless
  • Loading branch information
yngrdyn authored Sep 18, 2024
2 parents 398f95d + 5040e35 commit 38bb9bb
Show file tree
Hide file tree
Showing 266 changed files with 7,151 additions and 2,565 deletions.
9 changes: 7 additions & 2 deletions .buildkite/scripts/steps/functional/performance_playwright.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@ if [ "$BUILDKITE_PIPELINE_SLUG" == "kibana-performance-data-set-extraction" ]; t
node scripts/run_performance.js --kibana-install-dir "$KIBANA_BUILD_LOCATION" --skip-warmup
else
# pipeline should use bare metal static worker
echo "--- Running performance tests"
node scripts/run_performance.js --kibana-install-dir "$KIBANA_BUILD_LOCATION"
if [[ -z "${JOURNEYS_GROUP+x}" ]]; then
echo "--- Running performance tests"
node scripts/run_performance.js --kibana-install-dir "$KIBANA_BUILD_LOCATION"
else
echo "--- Running performance tests: '$JOURNEYS_GROUP' group"
node scripts/run_performance.js --kibana-install-dir "$KIBANA_BUILD_LOCATION" --group "$JOURNEYS_GROUP"
fi
fi

echo "--- Upload journey step screenshots"
Expand Down
3 changes: 2 additions & 1 deletion .devcontainer/.env.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# /bin/bash or /bin/zsh (oh-my-zsh is installed by default as well)
SHELL=/bin/bash
# Switch to 1 to enable FIPS environment, any other value to disable
# Switch to 1 to enable FIPS environment, any other value to disable,
# then close and reopen a new terminal to setup the environment
FIPS=0
5 changes: 5 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ WORKDIR ${KBN_DIR}

# Node and NVM setup
COPY .node-version /tmp/

USER vscode

RUN mkdir -p $NVM_DIR && \
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_VERSION}/install.sh | bash && \
. "$NVM_DIR/nvm.sh" && \
Expand All @@ -61,6 +64,8 @@ RUN mkdir -p $NVM_DIR && \
echo "source $NVM_DIR/nvm.sh" >> ${HOME}/.zshrc && \
chown -R 1000:1000 "${HOME}/.npm"

USER root

# Reload the env everytime a new shell is opened incase the .env file changed.
RUN echo "source $KBN_DIR/.devcontainer/scripts/env.sh" >> ${HOME}/.bashrc && \
echo "source $KBN_DIR/.devcontainer/scripts/env.sh" >> ${HOME}/.zshrc
Expand Down
21 changes: 21 additions & 0 deletions dev_docs/tutorials/performance/adding_performance_journey.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,27 @@ simulate real life internet connection. This means that all requests have a fixe
In order to keep track on performance metrics stability, journeys are run on main branch with a scheduled interval.
Bare metal machine is used to produce results as stable and reproducible as possible.

#### Running subset of journeys for the PR

Some code changes might affect the Kibana performance and it might be benefitial to run relevant journeys against the PR
and compare performance metrics vs. the ones on main branch.

In oder to trigger the build for Kibana PR, you can follow these steps:

- Create a new kibana-single-user-performance [build](https://buildkite.com/elastic/kibana-single-user-performance#new)
- Provide the following arguments:
- Branch: `refs/pull/<PR_number>/head`
- Under Options, set the environment variable: `JOURNEYS_GROUP=<group_name>`

Currently supported journey groups:

- kibanaStartAndLoad
- crud
- dashboard
- discover
- maps
- ml

#### Machine specifications

All benchmarks are run on bare-metal machines with the [following specifications](https://www.hetzner.com/dedicated-rootserver/ex100):
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1801,7 +1801,7 @@
"tape": "^5.0.1",
"terser": "^5.32.0",
"terser-webpack-plugin": "^4.2.3",
"tough-cookie": "^4.1.4",
"tough-cookie": "^5.0.0",
"tree-kill": "^1.2.2",
"ts-morph": "^15.1.0",
"tsd": "^0.31.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { registerAnalyticsContextProviderMock } from './chrome_service.test.mock
import { shallow, mount } from 'enzyme';
import React from 'react';
import * as Rx from 'rxjs';
import { toArray } from 'rxjs';
import { toArray, firstValueFrom } from 'rxjs';
import { injectedMetadataServiceMock } from '@kbn/core-injected-metadata-browser-mocks';
import { docLinksServiceMock } from '@kbn/core-doc-links-browser-mocks';
import { httpServiceMock } from '@kbn/core-http-browser-mocks';
Expand Down Expand Up @@ -556,6 +556,39 @@ describe('start', () => {
`);
});
});

describe('side nav', () => {
describe('isCollapsed$', () => {
it('should return false by default', async () => {
const { chrome, service } = await start();
const isCollapsed = await firstValueFrom(chrome.sideNav.getIsCollapsed$());
service.stop();
expect(isCollapsed).toBe(false);
});

it('should read the localStorage value', async () => {
store.set('core.chrome.isSideNavCollapsed', 'true');
const { chrome, service } = await start();
const isCollapsed = await firstValueFrom(chrome.sideNav.getIsCollapsed$());
service.stop();
expect(isCollapsed).toBe(true);
});
});

describe('setIsCollapsed', () => {
it('should update the isCollapsed$ observable', async () => {
const { chrome, service } = await start();
const isCollapsed$ = chrome.sideNav.getIsCollapsed$();
const isCollapsed = await firstValueFrom(isCollapsed$);

chrome.sideNav.setIsCollapsed(!isCollapsed);

const updatedIsCollapsed = await firstValueFrom(isCollapsed$);
service.stop();
expect(updatedIsCollapsed).toBe(!isCollapsed);
});
});
});
});

describe('stop', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import type { InternalChromeStart } from './types';
import { HeaderTopBanner } from './ui/header/header_top_banner';

const IS_LOCKED_KEY = 'core.chrome.isLocked';
const IS_SIDENAV_COLLAPSED_KEY = 'core.chrome.isSideNavCollapsed';
const SNAPSHOT_REGEX = /-snapshot/i;

interface ConstructorParams {
Expand Down Expand Up @@ -86,7 +87,9 @@ export class ChromeService {
private readonly docTitle = new DocTitleService();
private readonly projectNavigation: ProjectNavigationService;
private mutationObserver: MutationObserver | undefined;
private readonly isSideNavCollapsed$ = new BehaviorSubject<boolean>(true);
private readonly isSideNavCollapsed$ = new BehaviorSubject(
localStorage.getItem(IS_SIDENAV_COLLAPSED_KEY) === 'true'
);
private logger: Logger;
private isServerless = false;

Expand Down Expand Up @@ -360,6 +363,11 @@ export class ChromeService {
projectNavigation.setProjectName(projectName);
};

const setIsSideNavCollapsed = (isCollapsed: boolean) => {
localStorage.setItem(IS_SIDENAV_COLLAPSED_KEY, JSON.stringify(isCollapsed));
this.isSideNavCollapsed$.next(isCollapsed);
};

if (!this.params.browserSupportsCsp && injectedMetadata.getCspConfig().warnLegacyBrowsers) {
notifications.toasts.addWarning({
title: mountReactNode(
Expand Down Expand Up @@ -431,9 +439,8 @@ export class ChromeService {
docLinks={docLinks}
kibanaVersion={injectedMetadata.getKibanaVersion()}
prependBasePath={http.basePath.prepend}
toggleSideNav={(isCollapsed) => {
this.isSideNavCollapsed$.next(isCollapsed);
}}
isSideNavCollapsed$={this.isSideNavCollapsed$}
toggleSideNav={setIsSideNavCollapsed}
>
<SideNavComponent activeNodes={activeNodes} />
</ProjectHeader>
Expand Down Expand Up @@ -556,7 +563,10 @@ export class ChromeService {
getBodyClasses$: () => bodyClasses$.pipe(takeUntil(this.stop$)),
setChromeStyle,
getChromeStyle$: () => chromeStyle$,
getIsSideNavCollapsed$: () => this.isSideNavCollapsed$.asObservable(),
sideNav: {
getIsCollapsed$: () => this.isSideNavCollapsed$.asObservable(),
setIsCollapsed: setIsSideNavCollapsed,
},
getActiveSolutionNavId$: () => projectNavigation.getActiveSolutionNavId$(),
project: {
setHome: setProjectHome,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ describe('Header', () => {
navControlsCenter$: Rx.of([]),
navControlsRight$: Rx.of([]),
customBranding$: Rx.of({}),
isSideNavCollapsed$: Rx.of(false),
prependBasePath: (str) => `hello/world/${str}`,
toggleSideNav: jest.fn(),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export interface Props {
navControlsCenter$: Observable<ChromeNavControl[]>;
navControlsRight$: Observable<ChromeNavControl[]>;
prependBasePath: (url: string) => string;
isSideNavCollapsed$: Observable<boolean>;
toggleSideNav: (isCollapsed: boolean) => void;
}

Expand Down Expand Up @@ -248,7 +249,12 @@ export const ProjectHeader = ({
<EuiHeader position="fixed" className="header__firstBar">
<EuiHeaderSection grow={false} css={headerCss.leftHeaderSection}>
<Router history={application.history}>
<ProjectNavigation toggleSideNav={toggleSideNav}>{children}</ProjectNavigation>
<ProjectNavigation
isSideNavCollapsed$={observables.isSideNavCollapsed$}
toggleSideNav={toggleSideNav}
>
{children}
</ProjectNavigation>
</Router>

<EuiHeaderSectionItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,28 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import React, { useEffect, useRef, FC, PropsWithChildren } from 'react';
import React, { FC, PropsWithChildren } from 'react';
import { EuiCollapsibleNavBeta } from '@elastic/eui';
import useLocalStorage from 'react-use/lib/useLocalStorage';
import useObservable from 'react-use/lib/useObservable';
import type { Observable } from 'rxjs';

const LOCAL_STORAGE_IS_COLLAPSED_KEY = 'PROJECT_NAVIGATION_COLLAPSED' as const;
interface Props {
toggleSideNav: (isVisible: boolean) => void;
isSideNavCollapsed$: Observable<boolean>;
}

export const ProjectNavigation: FC<
PropsWithChildren<{ toggleSideNav: (isVisible: boolean) => void }>
> = ({ children, toggleSideNav }) => {
const isMounted = useRef(false);
const [isCollapsed, setIsCollapsed] = useLocalStorage(LOCAL_STORAGE_IS_COLLAPSED_KEY, false);
const onCollapseToggle = (nextIsCollapsed: boolean) => {
setIsCollapsed(nextIsCollapsed);
toggleSideNav(nextIsCollapsed);
};

useEffect(() => {
if (!isMounted.current && isCollapsed !== undefined) {
toggleSideNav(isCollapsed);
}
isMounted.current = true;
}, [isCollapsed, toggleSideNav]);
export const ProjectNavigation: FC<PropsWithChildren<Props>> = ({
children,
isSideNavCollapsed$,
toggleSideNav,
}) => {
const isCollapsed = useObservable(isSideNavCollapsed$, false);

return (
<EuiCollapsibleNavBeta
data-test-subj="projectLayoutSideNav"
initialIsCollapsed={isCollapsed}
onCollapseToggle={onCollapseToggle}
isCollapsed={isCollapsed}
onCollapseToggle={toggleSideNav}
css={
isCollapsed
? undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ const createStartContractMock = () => {
setBadge: jest.fn(),
getBreadcrumbs$: jest.fn(),
setBreadcrumbs: jest.fn(),
getIsSideNavCollapsed$: jest.fn(),
sideNav: {
getIsCollapsed$: jest.fn(),
setIsCollapsed: jest.fn(),
},
getBreadcrumbsAppendExtension$: jest.fn(),
setBreadcrumbsAppendExtension: jest.fn(),
getGlobalHelpExtensionMenuLinks$: jest.fn(),
Expand Down Expand Up @@ -94,7 +97,7 @@ const createStartContractMock = () => {
startContract.getIsNavDrawerLocked$.mockReturnValue(new BehaviorSubject(false));
startContract.getBodyClasses$.mockReturnValue(new BehaviorSubject([]));
startContract.hasHeaderBanner$.mockReturnValue(new BehaviorSubject(false));
startContract.getIsSideNavCollapsed$.mockReturnValue(new BehaviorSubject(false));
startContract.sideNav.getIsCollapsed$.mockReturnValue(new BehaviorSubject(false));
return startContract;
};

Expand Down
16 changes: 12 additions & 4 deletions packages/core/chrome/core-chrome-browser/src/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,18 @@ export interface ChromeStart {
*/
getChromeStyle$(): Observable<ChromeStyle>;

/**
* Get an observable of the current collapsed state of the side nav.
*/
getIsSideNavCollapsed$(): Observable<boolean>;
sideNav: {
/**
* Get an observable of the current collapsed state of the side nav.
*/
getIsCollapsed$(): Observable<boolean>;

/**
* Set the collapsed state of the side nav.
* @param isCollapsed The collapsed state of the side nav.
*/
setIsCollapsed(isCollapsed: boolean): void;
};

/**
* Get the id of the currently active project navigation or `null` otherwise.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { UiCounterMetricType } from '@kbn/analytics';
import type { FieldsMetadataPublicStart } from '@kbn/fields-metadata-plugin/public';
import { Draggable } from '@kbn/dom-drag-drop';
import type { DataView, DataViewField } from '@kbn/data-views-plugin/public';
import { Filter } from '@kbn/es-query';
import type { SearchMode } from '../../types';
import { FieldItemButton, type FieldItemButtonProps } from '../../components/field_item_button';
import {
Expand Down Expand Up @@ -200,6 +201,10 @@ export interface UnifiedFieldListItemProps {
* Item size
*/
size: FieldItemButtonProps<DataViewField>['size'];
/**
* Custom filters to apply for the field list, ex: namespace custom filter
*/
additionalFilters?: Filter[];
}

function UnifiedFieldListItemComponent({
Expand All @@ -223,6 +228,7 @@ function UnifiedFieldListItemComponent({
groupIndex,
itemIndex,
size,
additionalFilters,
}: UnifiedFieldListItemProps) {
const [infoIsOpen, setOpen] = useState(false);

Expand Down Expand Up @@ -288,6 +294,7 @@ function UnifiedFieldListItemComponent({
multiFields={multiFields}
dataView={dataView}
onAddFilter={addFilterAndClosePopover}
additionalFilters={additionalFilters}
/>

{searchMode === 'documents' && multiFields && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ export interface UnifiedFieldListItemStatsProps {
dataView: DataView;
multiFields?: Array<{ field: DataViewField; isSelected: boolean }>;
onAddFilter: FieldStatsProps['onAddFilter'];
additionalFilters?: FieldStatsProps['filters'];
}

export const UnifiedFieldListItemStats: React.FC<UnifiedFieldListItemStatsProps> = React.memo(
({ stateService, services, field, dataView, multiFields, onAddFilter }) => {
({ stateService, services, field, dataView, multiFields, onAddFilter, additionalFilters }) => {
const querySubscriberResult = useQuerySubscriber({
data: services.data,
timeRangeUpdatesType: stateService.creationOptions.timeRangeUpdatesType,
Expand All @@ -55,6 +56,11 @@ export const UnifiedFieldListItemStats: React.FC<UnifiedFieldListItemStatsProps>
[services]
);

const filters = useMemo(
() => [...(querySubscriberResult.filters ?? []), ...(additionalFilters ?? [])],
[querySubscriberResult.filters, additionalFilters]
);

if (!hasQuerySubscriberData(querySubscriberResult)) {
return null;
}
Expand All @@ -63,7 +69,7 @@ export const UnifiedFieldListItemStats: React.FC<UnifiedFieldListItemStatsProps>
<FieldStats
services={statsServices}
query={querySubscriberResult.query}
filters={querySubscriberResult.filters}
filters={filters}
fromDate={querySubscriberResult.fromDate}
toDate={querySubscriberResult.toDate}
dataViewOrDataViewId={dataView}
Expand Down
Loading

0 comments on commit 38bb9bb

Please sign in to comment.