Skip to content

Commit 009fdcc

Browse files
committed
[WIP] Add inspector for VEGA
Closes: #31189
1 parent 1c91b1c commit 009fdcc

File tree

38 files changed

+636
-58
lines changed

38 files changed

+636
-58
lines changed

src/plugins/data/public/search/aggs/buckets/terms.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export const getTermsBucketAgg = () =>
129129

130130
const response = await nestedSearchSource.fetch({ abortSignal });
131131
request
132-
.stats(getResponseInspectorStats(nestedSearchSource, response))
132+
.stats(getResponseInspectorStats(response, nestedSearchSource))
133133
.ok({ json: response });
134134
resp = mergeOtherBucketAggResponse(aggConfigs, resp, response, aggConfig, filterAgg());
135135
}

src/plugins/data/public/search/expressions/esaggs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ const handleCourierRequest = async ({
175175

176176
(searchSource as any).lastQuery = queryHash;
177177

178-
request.stats(getResponseInspectorStats(searchSource, response)).ok({ json: response });
178+
request.stats(getResponseInspectorStats(response, searchSource)).ok({ json: response });
179179

180180
(searchSource as any).rawResponse = response;
181181
} catch (e) {

src/plugins/data/public/search/expressions/utils/courier_inspector_stats.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ export function getRequestInspectorStats(searchSource: ISearchSource) {
6161

6262
/** @public */
6363
export function getResponseInspectorStats(
64-
searchSource: ISearchSource,
65-
resp: SearchResponse<unknown>
64+
resp: SearchResponse<unknown>,
65+
searchSource?: ISearchSource
6666
) {
67-
const lastRequest = searchSource.history && searchSource.history[searchSource.history.length - 1];
67+
const lastRequest =
68+
searchSource?.history && searchSource.history[searchSource.history.length - 1];
6869
const stats: RequestStatistics = {};
6970

7071
if (resp && resp.took) {

src/plugins/discover/public/application/angular/discover.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ function discoverController(
874874
}
875875

876876
function onResults(resp) {
877-
inspectorRequest.stats(getResponseInspectorStats($scope.searchSource, resp)).ok({ json: resp });
877+
inspectorRequest.stats(getResponseInspectorStats(resp, $scope.searchSource)).ok({ json: resp });
878878

879879
if (getTimeField()) {
880880
const tabifiedData = tabifyAggResponse($scope.vis.data.aggs, resp);

src/plugins/discover/public/application/embeddable/search_embeddable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ export class SearchEmbeddable extends Embeddable<SearchInput, SearchOutput>
307307
this.updateOutput({ loading: false, error: undefined });
308308

309309
// Log response to inspector
310-
inspectorRequest.stats(getResponseInspectorStats(searchSource, resp)).ok({ json: resp });
310+
inspectorRequest.stats(getResponseInspectorStats(resp, searchSource)).ok({ json: resp });
311311

312312
// Apply the changes to the angular scope
313313
this.searchScope.$apply(() => {

src/plugins/expressions/common/execution/execution.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { createExecutionContainer, ExecutionContainer } from './container';
2323
import { createError } from '../util';
2424
import { Defer, now } from '../../../kibana_utils/common';
2525
import { toPromise } from '../../../data/common/utils/abort_utils';
26-
import { RequestAdapter, DataAdapter } from '../../../inspector/common';
26+
import { RequestAdapter, DataAdapter, Adapters } from '../../../inspector/common';
2727
import { isExpressionValueError, ExpressionValueError } from '../expression_types/specs/error';
2828
import {
2929
ExpressionAstExpression,
@@ -70,7 +70,7 @@ export class Execution<
7070
ExtraContext extends Record<string, unknown> = Record<string, unknown>,
7171
Input = unknown,
7272
Output = unknown,
73-
InspectorAdapters = ExtraContext['inspectorAdapters'] extends object
73+
InspectorAdapters extends Adapters = ExtraContext['inspectorAdapters'] extends object
7474
? ExtraContext['inspectorAdapters']
7575
: DefaultInspectorAdapters
7676
> {

src/plugins/expressions/common/execution/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
*/
1919

2020
import { ExpressionType } from '../expression_types';
21-
import { DataAdapter, RequestAdapter } from '../../../inspector/common';
21+
import { Adapters, DataAdapter, RequestAdapter } from '../../../inspector/common';
2222
import { TimeRange, Query, Filter } from '../../../data/common';
2323
import { SavedObject, SavedObjectAttributes } from '../../../../core/public';
2424

2525
/**
2626
* `ExecutionContext` is an object available to all functions during a single execution;
2727
* it provides various methods to perform side-effects.
2828
*/
29-
export interface ExecutionContext<Input = unknown, InspectorAdapters = DefaultInspectorAdapters> {
29+
export interface ExecutionContext<Input = unknown, InspectorAdapters extends Adapters = Adapters> {
3030
/**
3131
* Get initial input with which execution started.
3232
*/
@@ -75,7 +75,7 @@ export interface ExecutionContext<Input = unknown, InspectorAdapters = DefaultIn
7575
/**
7676
* Default inspector adapters created if inspector adapters are not set explicitly.
7777
*/
78-
export interface DefaultInspectorAdapters {
78+
export interface DefaultInspectorAdapters extends Adapters {
7979
requests: RequestAdapter;
8080
data: DataAdapter;
8181
}

src/plugins/inspector/common/adapters/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,12 @@
1717
* under the License.
1818
*/
1919

20+
export { Adapters } from './types';
2021
export { DataAdapter, FormattedData } from './data';
21-
export { RequestAdapter, RequestStatistic, RequestStatistics, RequestStatus } from './request';
22+
export {
23+
RequestAdapter,
24+
RequestStatistic,
25+
RequestStatistics,
26+
RequestStatus,
27+
RequestResponder,
28+
} from './request';

src/plugins/inspector/common/adapters/request/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@
1919

2020
export { RequestStatistic, RequestStatistics, RequestStatus } from './types';
2121
export { RequestAdapter } from './request_adapter';
22+
export { RequestResponder } from './request_responder';
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
/**
21+
* The interface that the adapters used to open an inspector have to fullfill.
22+
*/
23+
export interface Adapters {
24+
[key: string]: any;
25+
}

0 commit comments

Comments
 (0)