Skip to content
Merged
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
18e5fc8
timing dashboard data loading
Jun 2, 2022
d1027ad
reporting loading \ error from all embeddables
Jun 13, 2022
ea42022
report event
Jun 13, 2022
2ccc4d2
lint
Jun 13, 2022
a0747f6
comment out console
Jun 13, 2022
0589135
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jun 13, 2022
3bf8787
Update embeddable_child_panel.tsx
lizozom Jun 14, 2022
061a352
Merge branch 'main' into dashboard-events
lizozom Jun 14, 2022
0a6f01e
Make analytics optional
Jun 14, 2022
3c0d7e7
Merge branch 'dashboard-events' of github.com:lizozom/kibana into das…
Jun 14, 2022
dcb10bd
Telemetry report to include both time to load data and time to render
Jun 16, 2022
93db343
Merge branch 'main' of https://github.com/elastic/kibana into dashboa…
Jun 16, 2022
b5171c4
Measure load time from beginning of mount
Jun 16, 2022
8325bc8
Merge branch 'main' of https://github.com/elastic/kibana into dashboa…
Jun 16, 2022
cacf761
lint
Jun 16, 2022
9f096fd
Merge branch 'main' of https://github.com/elastic/kibana into dashboa…
Jun 20, 2022
a0b9c79
Merge branch 'main' into dashboard-events
Jun 20, 2022
3deac1c
fix onDataLoadEnd and onDataLoadError event handler callbacks only ca…
nreese Jun 20, 2022
174b734
dataLoadEnd
nreese Jun 20, 2022
3a0a0a5
Merge branch 'main' of https://github.com/elastic/kibana into dashboa…
Jun 21, 2022
5d68d06
Merge branch 'dashboard-events' of github.com:lizozom/kibana into das…
Jun 21, 2022
e5cdea5
Merge remote-tracking branch 'nreese/issue_134785' into dashboard-events
Jun 21, 2022
eb8d634
code review
Jun 21, 2022
66ee132
imports
Jun 21, 2022
a23893d
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Jun 21, 2022
0450d69
comment
Jun 21, 2022
bb1f371
Merge branch 'dashboard-events' of github.com:lizozom/kibana into das…
Jun 21, 2022
dc7285f
Merge branch 'main' of https://github.com/elastic/kibana into dashboa…
Jun 21, 2022
d39fef1
Fix dedupe of events!
Jun 21, 2022
7e3e1e9
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Jun 21, 2022
8840e08
Merge branch 'main' of https://github.com/elastic/kibana into dashboa…
Jun 23, 2022
083b737
Rendered discover
Jun 23, 2022
6249903
Merge branch 'dashboard-events' of github.com:lizozom/kibana into das…
Jun 23, 2022
69525d5
oops
Jun 23, 2022
851b493
Code review + DashboardLoadedEvent
Jun 23, 2022
6d4c422
reportsEmbeddableLoad
Jun 23, 2022
287d2b6
type
Jun 23, 2022
05f5543
isNil
Jun 23, 2022
a6bb540
Merge branch 'main' of https://github.com/elastic/kibana into dashboa…
Jun 23, 2022
5c45fe6
fix sync unsubscribe
Jun 23, 2022
78752c6
use store state instead of eventHandlers
nreese Jun 23, 2022
34e062f
Merge branch 'main' of https://github.com/elastic/kibana into dashboa…
Jun 27, 2022
bbe8f31
Merge pull request #9 from nreese/lizozom/dashboard-events
lizozom Jun 27, 2022
b19b052
[EBT] Better FTR helper APIs
afharo Jun 28, 2022
f85b09a
dashboard loaded telemetry test
Jun 28, 2022
280d616
Merge remote-tracking branch 'afharo/test-analytics-ftr-apis' into da…
Jun 28, 2022
aa48aa2
timestamp
Jun 28, 2022
25b9bb4
Merge branch 'main' of https://github.com/elastic/kibana into dashboa…
Jun 28, 2022
61f589b
Merge branch 'dashboard-events' of github.com:lizozom/kibana into das…
Jun 28, 2022
87584de
Merge branch 'main' of https://github.com/elastic/kibana into dashboa…
Jul 7, 2022
361cdf1
Merge branch 'main' of https://github.com/elastic/kibana into dashboa…
Jul 7, 2022
5cb32ee
tests
Jul 7, 2022
a42f9ae
tests
Jul 7, 2022
9331968
[CI] Auto-commit changed files from 'node scripts/precommit_hook.js -…
kibanamachine Jul 7, 2022
9cd0233
test
Jul 7, 2022
a045f90
docs + longer timeout
Jul 7, 2022
a3648c9
Merge branch 'main' of https://github.com/elastic/kibana into dashboa…
Jul 7, 2022
6851ae1
Merge branch 'dashboard-events' of github.com:lizozom/kibana into das…
Jul 7, 2022
c93fc14
Merge branch 'main' of https://github.com/elastic/kibana into dashboa…
Jul 11, 2022
c994f3e
fix
Jul 11, 2022
b7d4114
Fix property inheritance and map events
Jul 11, 2022
a6bf8f8
type error
Jul 11, 2022
7070630
reportsEmbeddableLoad
Jul 12, 2022
5180eb3
tests
Jul 12, 2022
fe7f9db
Merge branch 'main' of https://github.com/elastic/kibana into dashboa…
Jul 12, 2022
73e33af
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jul 12, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import { CoreStart, IUiSettingsClient, KibanaExecutionContext } from '@kbn/core/
import { Start as InspectorStartContract } from '@kbn/inspector-plugin/public';

import { ControlGroupContainer } from '@kbn/controls-plugin/public';
import { Filter, TimeRange } from '@kbn/es-query';
import { UiActionsStart } from '../../services/ui_actions';
import { RefreshInterval, TimeRange, Query, Filter } from '../../services/data';
import { RefreshInterval, Query } from '../../services/data';
import {
ViewMode,
Container,
Expand All @@ -30,7 +31,7 @@ import {
} from '../../services/embeddable';
import { DASHBOARD_CONTAINER_TYPE } from './dashboard_constants';
import { createPanelState } from './panel';
import { DashboardPanelState } from './types';
import { DashboardLoadedEvent, DashboardPanelState } from './types';
import { DashboardViewport } from './viewport/dashboard_viewport';
import {
KibanaContextProvider,
Expand Down Expand Up @@ -62,6 +63,7 @@ export interface DashboardContainerServices {
uiActions: UiActionsStart;
theme: CoreStart['theme'];
http: CoreStart['http'];
analytics?: CoreStart['analytics'];
}

interface IndexSignature {
Expand Down Expand Up @@ -153,6 +155,12 @@ export class DashboardContainer extends Container<InheritedChildInput, Dashboard
}
}

private onDataLoaded(data: DashboardLoadedEvent) {
this.services.analytics?.reportEvent('dashboard-data-loaded', {
...data,
});
}

protected createNewPanelState<
TEmbeddableInput extends EmbeddableInput,
TEmbeddable extends IEmbeddable<TEmbeddableInput, any>
Expand Down Expand Up @@ -289,6 +297,7 @@ export class DashboardContainer extends Container<InheritedChildInput, Dashboard
controlsEnabled={controlsEnabled}
container={this}
controlGroup={this.controlGroup}
onDataLoaded={this.onDataLoaded.bind(this)}
/>
</this.services.presentationUtil.ContextProvider>
</KibanaThemeProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import React from 'react';
import { Subscription } from 'rxjs';
import ReactGridLayout, { Layout, ReactGridLayoutProps } from 'react-grid-layout';
import { GridData } from '../../../../common';
import { ViewMode } from '../../../services/embeddable';
import { ViewMode, EmbeddablePhaseEvent } from '../../../services/embeddable';
import { DASHBOARD_GRID_COLUMN_COUNT, DASHBOARD_GRID_HEIGHT } from '../dashboard_constants';
import { DashboardPanelState } from '../types';
import { DashboardLoadedEventStatus, DashboardLoadedEvent, DashboardPanelState } from '../types';
import { withKibana } from '../../../services/kibana_react';
import { DashboardContainer, DashboardReactContextValue } from '../dashboard_container';
import { DashboardGridItem } from './dashboard_grid_item';
Expand Down Expand Up @@ -105,6 +105,7 @@ const ResponsiveSizedGrid = sizeMe(config)(ResponsiveGrid);
export interface DashboardGridProps extends ReactIntl.InjectedIntlProps {
kibana: DashboardReactContextValue;
container: DashboardContainer;
onDataLoaded?: (data: DashboardLoadedEvent) => void;
}

interface State {
Expand Down Expand Up @@ -230,9 +231,9 @@ class DashboardGridUi extends React.Component<DashboardGridProps, State> {
const isViewMode = viewMode === ViewMode.VIEW;

// Part of our unofficial API - need to render in a consistent order for plugins.
const panelsInOrder = Object.keys(panels).map(
(key: string) => panels[key] as DashboardPanelState
);
const panelsInOrder = Object.keys(panels).map((key: string) => {
return panels[key] as DashboardPanelState;
});

panelsInOrder.sort((panelA, panelB) => {
if (panelA.gridData.y === panelB.gridData.y) {
Expand All @@ -242,6 +243,46 @@ class DashboardGridUi extends React.Component<DashboardGridProps, State> {
}
});

const panelIds: Record<string, Record<string, number>> = {};
const loadStartTime = performance.now();
let lastTimeToData = 0;
let status: DashboardLoadedEventStatus = 'done';
let doneCount = 0;

/**
* Sends an event
*
* @param info
* @returns
*/
const onPanelStatusChange = (info: EmbeddablePhaseEvent) => {
if (!this.props.onDataLoaded) return;

if (panelIds[info.id] === undefined || info.status === 'loading') {
panelIds[info.id] = {};
} else if (info.status === 'error') {
status = 'error';
} else if (info.status === 'loaded') {
lastTimeToData = performance.now();
}

panelIds[info.id][info.status] = performance.now();

if (info.status === 'error' || info.status === 'rendered') {
doneCount++;
if (doneCount === panelsInOrder.length) {
const doneTime = performance.now();
const data: DashboardLoadedEvent = {
timeToData: (lastTimeToData || doneTime) - loadStartTime,
timeToDone: doneTime - loadStartTime,
numOfPanels: panelsInOrder.length,
status,
};
this.props.onDataLoaded(data);
}
}
};

const dashboardPanels = _.map(panelsInOrder, ({ explicitInput, type }, index) => (
<DashboardGridItem
key={explicitInput.id}
Expand All @@ -252,6 +293,7 @@ class DashboardGridUi extends React.Component<DashboardGridProps, State> {
PanelComponent={kibana.services.embeddable.EmbeddablePanel}
expandedPanelId={expandedPanelId}
focusedPanelId={focusedPanelIndex}
onPanelStatusChange={onPanelStatusChange}
/>
));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import React, { useState, useRef, useEffect, FC } from 'react';
import { EuiLoadingChart } from '@elastic/eui';
import classNames from 'classnames';

import { EmbeddableChildPanel, ViewMode } from '../../../services/embeddable';
import { EmbeddableChildPanel, EmbeddablePhaseEvent, ViewMode } from '../../../services/embeddable';
import { useLabs } from '../../../services/presentation_util';
import { DashboardPanelState } from '../types';
import { DashboardContainer } from '..';
Expand All @@ -27,6 +27,7 @@ interface Props extends PanelProps, DivProps {
expandedPanelId?: string;
key: string;
isRenderable?: boolean;
onPanelStatusChange?: (info: EmbeddablePhaseEvent) => void;
}

const Item = React.forwardRef<HTMLDivElement, Props>(
Expand All @@ -39,6 +40,7 @@ const Item = React.forwardRef<HTMLDivElement, Props>(
index,
PanelComponent,
type,
onPanelStatusChange,
isRenderable = true,
// The props below are passed from ReactGridLayoutn and need to be merged with their counterparts.
// https://github.com/react-grid-layout/react-grid-layout/issues/1241#issuecomment-658306889
Expand Down Expand Up @@ -73,6 +75,7 @@ const Item = React.forwardRef<HTMLDivElement, Props>(
key={type}
embeddableId={id}
index={index}
onPanelStatusChange={onPanelStatusChange}
{...{ container, PanelComponent }}
/>
{children}
Expand Down
11 changes: 11 additions & 0 deletions src/plugins/dashboard/public/application/embeddable/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,14 @@
*/

export * from '../../../common/types';

export type DashboardLoadedEventStatus = 'done' | 'error';

export interface DashboardLoadedEvent {
// Time from start to when data is loaded
timeToData: number;
// Time from start until render or error
timeToDone: number;
numOfPanels: number;
status: DashboardLoadedEventStatus;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ import { DashboardGrid } from '../grid';
import { context } from '../../../services/kibana_react';
import { DashboardEmptyScreen } from '../empty_screen/dashboard_empty_screen';
import { withSuspense } from '../../../services/presentation_util';
import { DashboardLoadedEvent } from '../types';

export interface DashboardViewportProps {
container: DashboardContainer;
controlGroup?: ControlGroupContainer;
controlsEnabled?: boolean;
onDataLoaded?: (data: DashboardLoadedEvent) => void;
}

interface State {
Expand Down Expand Up @@ -155,7 +157,9 @@ export class DashboardViewport extends React.Component<DashboardViewportProps, S
/>
</div>
)}
{this.state.controlGroupReady && <DashboardGrid container={container} />}
{this.state.controlGroupReady && (
<DashboardGrid container={container} onDataLoaded={this.props.onDataLoaded} />
)}
</div>
</>
);
Expand Down
28 changes: 28 additions & 0 deletions src/plugins/dashboard/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import {
LibraryNotificationAction,
CopyToDashboardAction,
DashboardCapabilities,
DashboardLoadedEvent,
} from './application';
import { DashboardAppLocatorDefinition, DashboardAppLocator } from './locator';
import { createSavedDashboardLoader } from './saved_dashboards';
Expand Down Expand Up @@ -138,6 +139,30 @@ export class DashboardPlugin
private dashboardFeatureFlagConfig?: DashboardFeatureFlagConfig;
private locator?: DashboardAppLocator;

private registerEvents(analytics: CoreSetup['analytics']) {
analytics.registerEventType<DashboardLoadedEvent>({
eventType: 'dashboard-data-loaded',
schema: {
timeToData: {
type: 'long',
_meta: { description: 'Time all embeddables took to load data' },
},
timeToDone: {
type: 'long',
_meta: { description: 'Time all embeddables took to load data' },
},
status: {
type: 'keyword',
_meta: { description: 'Error ok' },
},
numOfPanels: {
type: 'long',
_meta: { description: 'Number of panels loaded' },
},
},
});
}

public setup(
core: CoreSetup<DashboardStartDependencies, DashboardStart>,
{
Expand Down Expand Up @@ -172,6 +197,7 @@ export class DashboardPlugin
application: coreStart.application,
uiSettings: coreStart.uiSettings,
overlays: coreStart.overlays,
analytics: coreStart.analytics,
embeddable: deps.embeddable,
uiActions: deps.uiActions,
inspector: deps.inspector,
Expand Down Expand Up @@ -286,6 +312,8 @@ export class DashboardPlugin
},
};

this.registerEvents(core.analytics);

core.application.register(app);
urlForwarding.forwardApp(
DashboardConstants.DASHBOARDS_ID,
Expand Down
26 changes: 23 additions & 3 deletions src/plugins/discover/public/embeddable/saved_search_embeddable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ export class SavedSearchEmbeddable

private node?: HTMLElement;

reportsEmbeddableLoad = true;

constructor(
{
savedSearch,
Expand Down Expand Up @@ -172,7 +174,12 @@ export class SavedSearchEmbeddable

this.searchProps!.isLoading = true;

this.updateOutput({ loading: true, error: undefined });
this.updateOutput({
...this.getOutput(),
loading: true,
rendered: false,
error: undefined,
});

const parentContext = this.input.executionContext;
const child: KibanaExecutionContext = {
Expand Down Expand Up @@ -208,7 +215,11 @@ export class SavedSearchEmbeddable
executionContext,
})
);
this.updateOutput({ loading: false, error: undefined });

this.updateOutput({
...this.getOutput(),
loading: false,
});

this.searchProps!.rows = resp.hits.hits.map((hit) =>
buildDataTableRecord(hit, this.searchProps!.indexPattern)
Expand All @@ -217,7 +228,11 @@ export class SavedSearchEmbeddable
this.searchProps!.isLoading = false;
} catch (error) {
if (!this.destroyed) {
this.updateOutput({ loading: false, error });
this.updateOutput({
...this.getOutput(),
loading: false,
error,
});

this.searchProps!.isLoading = false;
}
Expand Down Expand Up @@ -455,6 +470,11 @@ export class SavedSearchEmbeddable
domNode
);
}

this.updateOutput({
...this.getOutput(),
rendered: true,
});
}

public reload() {
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/embeddable/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export type {
ContainerOutput,
EmbeddableChildPanelProps,
EmbeddableContext,
EmbeddablePhaseEvent,
EmbeddablePhase,
EmbeddableFactory,
EmbeddableFactoryDefinition,
EmbeddableInput,
Expand Down
Loading