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

[Discover] Update unified histogram to use Lens #143117

Merged
Merged
Changes from 1 commit
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
fe306b0
[Discover] Start updating unified histogram to use Lens
davismcphee Oct 13, 2022
4f09f75
[Discover] Add filters and query support to unified histogram
davismcphee Oct 13, 2022
5847970
[Discover] Update indexpattern to formBased in Lens config
davismcphee Oct 14, 2022
ea02b13
[Discover] Fix histogram time interval
davismcphee Oct 15, 2022
54fc5e1
[Discover] Continue adding support for histogram breakdown
davismcphee Oct 17, 2022
16d2824
[Discover] Removing Discover dependency from Lens
davismcphee Oct 17, 2022
6ea0ade
[Discover] Finish removing Discover dependencies from Lens
davismcphee Oct 18, 2022
954ba1c
[Discover] Add support for breakdown field selector to unifiedHistogram
davismcphee Oct 24, 2022
9084844
[Discover] Fix Lens histogram loading indicator position
davismcphee Oct 24, 2022
5578336
[Discover] Fix Lens histogram not reacting to query/filter change
davismcphee Oct 24, 2022
9cccac2
[Discover] Add support for total hits
davismcphee Oct 25, 2022
db92baa
[Discover] Removed chart data fetching from Discover and Unified Hist…
davismcphee Oct 26, 2022
838445c
[Discover] Update unfiied histogram to make total hits request
davismcphee Oct 29, 2022
017a7cb
[Discover] Moved breakdown field to URL app state instead of local st…
davismcphee Nov 2, 2022
f38547e
[Discover] Updating histogram labels and settings
davismcphee Nov 3, 2022
7d00ff8
[Discover] fix functionals
dimaanj Nov 3, 2022
d362441
Merge pull request #1 from dimaanj/fix-functionals-of-histogram-as-le…
davismcphee Nov 3, 2022
4c68c1b
[Discover] Add support for inspecting Lens requests in Discover
davismcphee Nov 3, 2022
1543ff6
[Discover] Clear Lens request adapter on chart hidden
davismcphee Nov 3, 2022
8c5a9fb
[Discover] Field unified histogram breakdown fields
davismcphee Nov 4, 2022
8482445
[Discover] Fix Lens services breaking from merge
davismcphee Nov 4, 2022
f19c72a
[Discover] Fix grid rendering when chart visibility changes
davismcphee Nov 4, 2022
f7384af
[Discover] Fix issue where time range in total hits request was not b…
davismcphee Nov 4, 2022
af9a681
[Discover] Improve time range text loading state
davismcphee Nov 4, 2022
3186657
[Discover] fix dashboard tests
dimaanj Nov 4, 2022
3e4418b
[Discover] fix jest tests
dimaanj Nov 4, 2022
e45eef3
[Discover] fix some jest tests
dimaanj Nov 4, 2022
191c1ac
Merge pull request #2 from dimaanj/fix-ci-unified-histogram-pr
davismcphee Nov 5, 2022
b100682
[Discover] Clean up doc table force rerender code
davismcphee Nov 7, 2022
e047d7c
[Discover] Make lastReloadRequestTime a top level prop
davismcphee Nov 7, 2022
2848897
[Discover] Update queryStateContainer to be a ref
davismcphee Nov 7, 2022
ee84cf8
[Discover] Add documentation for useTotalHits
davismcphee Nov 7, 2022
b07d286
[Discover] Change UnifiedHistogramFetchStatus to an enum
davismcphee Nov 7, 2022
633db2c
[Discover] Fix issue where unified histogram doesn't start fetching u…
davismcphee Nov 8, 2022
d646cb3
Implement saved search breakdownField persistence
kertal Nov 8, 2022
5315030
Merge branch 'enhancement-unified-histogram-lens' of github.com:davis…
kertal Nov 8, 2022
fff2b03
[Discover] improve tests
dimaanj Nov 8, 2022
16b7c4e
Merge pull request #3 from dimaanj/improve-tests
davismcphee Nov 8, 2022
042c700
[Discover] Make fetchAll wait on unified histogram to finish loading …
davismcphee Nov 8, 2022
43c00f6
[Discover] Include 'other' bucket in unified histogram
davismcphee Nov 8, 2022
ef02c44
[Discover] Skip first lastReloadRequestTime effect
davismcphee Nov 8, 2022
801e6a3
[Discover] Hide breakdown if undefined
davismcphee Nov 9, 2022
bfb7b24
[Discover] Use search session to determine when to fetch unified hist…
davismcphee Nov 9, 2022
0e6de80
[Discover] Prevent hits.total changes triggering a Lens refetch
davismcphee Nov 9, 2022
4ca75e3
[Discover] Use refetchId to determine when unified histogram should r…
davismcphee Nov 9, 2022
ff69195
[Discover] fix some tests
dimaanj Nov 9, 2022
192fcec
[Discover] cleanup
davismcphee Nov 9, 2022
c40eda8
[Discover] Refetch data when chart visibility is toggled or breakdown…
davismcphee Nov 9, 2022
8efb7a4
Merge branch 'main' into enhancement-unified-histogram-lens
davismcphee Nov 10, 2022
b94bcc7
Merge remote-tracking branch 'davis-remote/enhancement-unified-histog…
dimaanj Nov 11, 2022
6bce46e
[Discover] fix include typings
dimaanj Nov 11, 2022
b582bc7
[Discover] try to fix type check failure
dimaanj Nov 11, 2022
26b2feb
[Discover] fix discover layout test
dimaanj Nov 11, 2022
b59058d
[Discover] fix ts config
dimaanj Nov 11, 2022
4a992b1
[Discover] fix tests
dimaanj Nov 14, 2022
6121d61
[Discover] fix ci
dimaanj Nov 14, 2022
b0bff11
[Discover] add navigation to Lens using breakdown by field
dimaanj Nov 15, 2022
76d8e35
[Discover] fix tests
dimaanj Nov 15, 2022
274f0df
[Discover] fix remaining tests
dimaanj Nov 15, 2022
28827a7
Merge pull request #4 from dimaanj/fix-some-tests
davismcphee Nov 16, 2022
c76c8f9
Merge branch 'main' into enhancement-unified-histogram-lens
davismcphee Nov 16, 2022
a2b6221
[Discover] enable navigation from Lens with breakdown field
dimaanj Nov 16, 2022
dc3097d
Merge branch 'main' into enhancement-unified-histogram-lens
kibanamachine Nov 16, 2022
f3f3f88
[Discover] Cleaning up some component and prop names, and fixing dupl…
davismcphee Nov 16, 2022
1ddef16
[Discover] Fix use_discover_histogram.test.ts types
davismcphee Nov 16, 2022
f2eda4a
[Discover] Show current time marker
davismcphee Nov 16, 2022
6c660d0
[Discover] Fixed issue with total hits loading flicker on refetch
davismcphee Nov 16, 2022
e66de99
[Discover] Fix and add new tests for use_discover_histogram.test.tsx
davismcphee Nov 16, 2022
c3b315a
[Discover] Make sure the breakdown field is accounted for when saving…
davismcphee Nov 16, 2022
932d276
[Discover] Fix broken types from Jest test fix
davismcphee Nov 16, 2022
9fd9c5b
[Discover] Updating and fixing Jest tests
davismcphee Nov 17, 2022
b302478
[Discover] Add Discover loading spinner back in
davismcphee Nov 17, 2022
963ae17
[Discover] Upating comments in use_discover_histogram
davismcphee Nov 17, 2022
b53cf5b
[Discover] Add Jest tests for new files
davismcphee Nov 18, 2022
d057d9f
[Discover] Updating existing Jest tests for new functionality
davismcphee Nov 18, 2022
dc2ea16
Merge branch 'main' into enhancement-unified-histogram-lens
davismcphee Nov 18, 2022
d9f71f9
[Discover] Fix flaky histogram shown/hidden functional tests
davismcphee Nov 18, 2022
8835af0
[Discover] Added Jest tests for histogram.tsx
davismcphee Nov 18, 2022
c86627f
Merge branch 'main' into enhancement-unified-histogram-lens
kibanamachine Nov 21, 2022
4754d20
Merge branch 'main' into enhancement-unified-histogram-lens
davismcphee Nov 21, 2022
27922b3
[Discover] Add placeholder text to breakdown_field_selector
davismcphee Nov 21, 2022
900877d
[Discover] do not bring breakdown field on Lens to Discover navigation
dimaanj Nov 22, 2022
dd49efe
Merge branch 'main' into enhancement-unified-histogram-lens
davismcphee Nov 22, 2022
395f570
[Discover] Rollback Lens visualize button changes and update Discover…
davismcphee Nov 22, 2022
6ace558
Merge branch 'main' into enhancement-unified-histogram-lens
davismcphee Nov 23, 2022
6cc4f6c
Merge branch 'main' into enhancement-unified-histogram-lens
kibanamachine Nov 24, 2022
5c8e0f9
[Discover] Added tooltip to breakdown field selector
davismcphee Nov 25, 2022
84c0d74
[Discover] Remove dscPageContent__inner class, add Lens input title s…
davismcphee Nov 28, 2022
bbd0ce0
[Discover] Add default unified histogram Lens input title
davismcphee Nov 28, 2022
46ef36a
[Discover] Remove duplicate .dscPageContent selector from discover_la…
davismcphee Nov 29, 2022
2352b8c
[Discover] Add breakdown selector aria label
davismcphee Nov 30, 2022
e4b6a0d
[Discover] Fix elements overflowing the histogram container at small …
davismcphee Nov 30, 2022
58e8949
Merge branch 'main' into enhancement-unified-histogram-lens
davismcphee Nov 30, 2022
b69f071
[Discover] Update check_registered_types test
davismcphee Nov 30, 2022
b5742b6
[Discover] Update time range 'loading...' to 'Loading'
davismcphee Nov 30, 2022
59be2b0
[Discover] Emit an error when Lens fails so that Discover doesn't dis…
davismcphee Nov 30, 2022
0aa75a3
Merge branch 'main' into enhancement-unified-histogram-lens
davismcphee Dec 1, 2022
467eab6
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Dec 1, 2022
7a126b0
Merge branch 'main' into enhancement-unified-histogram-lens
davismcphee Dec 1, 2022
7f291a8
[Discover] Update breakdownField to be text type
davismcphee Dec 1, 2022
34d925c
Merge branch 'main' into enhancement-unified-histogram-lens
davismcphee Dec 1, 2022
194796e
Merge branch 'main' into enhancement-unified-histogram-lens
davismcphee Dec 2, 2022
2a9d568
Merge branch 'main' into enhancement-unified-histogram-lens
davismcphee Dec 3, 2022
5ce0423
[Discover] Fix false positives when setting chartDisplayChanged, caus…
davismcphee Dec 3, 2022
25f23d6
[Discover] Fix flaky autorefresh test
davismcphee Dec 3, 2022
26ecfad
Merge branch 'main' into enhancement-unified-histogram-lens
davismcphee Dec 5, 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
Prev Previous commit
Next Next commit
[Discover] Emit an error when Lens fails so that Discover doesn't dis…
…play 'no hits'
davismcphee committed Nov 30, 2022
commit 59be2b0ca5a0e0f447dfa704024a7e97248c5152
2 changes: 1 addition & 1 deletion src/plugins/unified_histogram/kibana.json
Original file line number Diff line number Diff line change
@@ -11,5 +11,5 @@
"ui": true,
"requiredPlugins": [],
"optionalPlugins": [],
"requiredBundles": ["data", "dataViews", "embeddable", "kibanaUtils"]
"requiredBundles": ["data", "dataViews", "embeddable", "kibanaUtils", "inspector"]
}
42 changes: 42 additions & 0 deletions src/plugins/unified_histogram/public/chart/histogram.test.tsx
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ import { REQUEST_DEBOUNCE_MS } from './consts';
import { act } from 'react-dom/test-utils';
import * as buildBucketInterval from './build_bucket_interval';
import * as useTimeRange from './use_time_range';
import { RequestStatus } from '@kbn/inspector-plugin/public';

const mockBucketInterval = { description: '1 minute', scale: undefined, scaled: false };
jest.spyOn(buildBucketInterval, 'buildBucketInterval').mockReturnValue(mockBucketInterval);
@@ -183,6 +184,47 @@ describe('Histogram', () => {
);
});

it('should execute onLoad correctly when the request has a failure status', async () => {
const { component, props } = mountComponent();
const embeddable = unifiedHistogramServicesMock.lens.EmbeddableComponent;
const onLoad = component.find(embeddable).props().onLoad;
const adapters = createDefaultInspectorAdapters();
jest
.spyOn(adapters.requests, 'getRequests')
.mockReturnValue([{ status: RequestStatus.ERROR } as any]);
onLoad(false, adapters);
expect(props.onTotalHitsChange).toHaveBeenLastCalledWith(
UnifiedHistogramFetchStatus.error,
undefined
);
expect(props.onChartLoad).toHaveBeenLastCalledWith({ complete: false, adapters });
});

it('should execute onLoad correctly when the response has shard failures', async () => {
const { component, props } = mountComponent();
const embeddable = unifiedHistogramServicesMock.lens.EmbeddableComponent;
const onLoad = component.find(embeddable).props().onLoad;
const adapters = createDefaultInspectorAdapters();
const rawResponse = {
_shards: {
total: 1,
successful: 0,
skipped: 0,
failed: 1,
failures: [],
},
};
jest
.spyOn(adapters.requests, 'getRequests')
.mockReturnValue([{ response: { json: { rawResponse } } } as any]);
onLoad(false, adapters);
expect(props.onTotalHitsChange).toHaveBeenLastCalledWith(
UnifiedHistogramFetchStatus.error,
undefined
);
expect(props.onChartLoad).toHaveBeenLastCalledWith({ complete: false, adapters });
});

it('should not recreate onLoad in debounced lens props when hits.total changes', async () => {
const { component, props } = mountComponent();
const embeddable = unifiedHistogramServicesMock.lens.EmbeddableComponent;
21 changes: 17 additions & 4 deletions src/plugins/unified_histogram/public/chart/histogram.tsx
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ import type { TimeRange } from '@kbn/es-query';
import useDebounce from 'react-use/lib/useDebounce';
import { ViewMode } from '@kbn/embeddable-plugin/public';
import type { TypedLensByValueInput } from '@kbn/lens-plugin/public';
import { RequestStatus } from '@kbn/inspector-plugin/public';
import {
UnifiedHistogramBucketInterval,
UnifiedHistogramChartContext,
@@ -73,17 +74,29 @@ export function Histogram({

const onLoad = useCallback(
(isLoading: boolean, adapters: Partial<DefaultInspectorAdapters> | undefined) => {
const lensRequest = adapters?.requests?.getRequests()[0];
const requestFailed = lensRequest?.status === RequestStatus.ERROR;
const json = lensRequest?.response?.json as
| IKibanaSearchResponse<estypes.SearchResponse>
| undefined;
const response = json?.rawResponse;

// Lens will swallow shard failures and return `isLoading: false` because it displays
// its own errors, but this causes us to emit onTotalHitsChange(UnifiedHistogramFetchStatus.complete, 0).
// This is incorrect, so we check for request failures and shard failures here, and emit an error instead.
if (requestFailed || response?._shards.failed) {
onTotalHitsChange?.(UnifiedHistogramFetchStatus.error, undefined);
onChartLoad?.({ complete: false, adapters: adapters ?? {} });
return;
}

const totalHits = adapters?.tables?.tables?.unifiedHistogram?.meta?.statistics?.totalCount;

onTotalHitsChange?.(
isLoading ? UnifiedHistogramFetchStatus.loading : UnifiedHistogramFetchStatus.complete,
totalHits ?? previousHits.current
);

const lensRequest = adapters?.requests?.getRequests()[0];
const json = lensRequest?.response?.json as IKibanaSearchResponse<estypes.SearchResponse>;
const response = json?.rawResponse;

if (response) {
const newBucketInterval = buildBucketInterval({
data,