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

Adds new elasticsearch client to telemetry plugin #78046

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
4c88237
Adds new elasticsearch client to telemetry plugin
TinaHeiligers Aug 27, 2020
57dfd55
Adds esClient getter to local_xpack and monitoring setCollection
TinaHeiligers Aug 27, 2020
844fc51
Provides the new es client to the stats collection config
TinaHeiligers Aug 28, 2020
21f3261
Adds asInternalUser to bulkFetch
TinaHeiligers Aug 28, 2020
dbaa02e
TODO: add scopedEsClient to remaining bulkFetch calls
TinaHeiligers Aug 28, 2020
50e2d1f
Adds esClient to all internal getters, adds hardcoded useLegacy boole…
TinaHeiligers Aug 31, 2020
149e51c
Adds license getter for new client
TinaHeiligers Sep 1, 2020
12a7af6
Types get_data_telemetry
TinaHeiligers Sep 2, 2020
c3bb50f
Review comments WIP
TinaHeiligers Sep 9, 2020
f9bcee2
Addresses review comments wrt get_data_telemetry.ts
TinaHeiligers Sep 9, 2020
6fd3088
Removes optional undefined from esClientGetter types and adds new cli…
TinaHeiligers Sep 9, 2020
4ada48e
Temporarily sets the elasticsearchClient as the new ES client in Moni…
TinaHeiligers Sep 9, 2020
fa3b33f
WIP review comments
TinaHeiligers Sep 14, 2020
c6e3a8d
Merge branch 'master' of github.com:elastic/kibana into usage-collect…
TinaHeiligers Sep 14, 2020
354240c
Fixes type issue
TinaHeiligers Sep 14, 2020
1ebf1e8
Adds undefined back to StatsCollectionConfig with comments, sets all …
TinaHeiligers Sep 14, 2020
6833a92
Removes callCluster and boolean from internal collection
TinaHeiligers Sep 14, 2020
17abcab
removes callCluster from xpack_collection
TinaHeiligers Sep 14, 2020
83e077e
Merge branch 'master' into usage-collection-with-new-esClient
TinaHeiligers Sep 15, 2020
632ce43
unit test refactors
TinaHeiligers Sep 16, 2020
d807edb
Merge branch 'master' into usage-collection-with-new-esClient
TinaHeiligers Sep 16, 2020
4f8bf2b
Merge branch 'master' into usage-collection-with-new-esClient
TinaHeiligers Sep 17, 2020
c6d1268
refactors get_data_telemetry unit tests
TinaHeiligers Sep 17, 2020
d1a302c
Merge branch 'master' into usage-collection-with-new-esClient
TinaHeiligers Sep 18, 2020
298dbda
Refactors usage_collection server unit tests
TinaHeiligers Sep 18, 2020
9d2a25d
defines type for stats route
TinaHeiligers Sep 18, 2020
3973824
deletes commented out code
TinaHeiligers Sep 18, 2020
0cafa04
Refactors get_xpack unit test and converts to jest
TinaHeiligers Sep 19, 2020
2c83436
Merge branch 'master' into usage-collection-with-new-esClient
TinaHeiligers Sep 19, 2020
cf2a172
refactors unit tests in telemetry plugin server
TinaHeiligers Sep 20, 2020
51e97de
Merge branch 'master' into usage-collection-with-new-esClient
TinaHeiligers Sep 21, 2020
2d7cc63
Updates documentation, removes comment
TinaHeiligers Sep 21, 2020
731cc20
removes changes in monitoring bulk_uploader file
TinaHeiligers Sep 21, 2020
3b305b9
self review
TinaHeiligers Sep 21, 2020
682e895
removes exclusive test check
TinaHeiligers Sep 21, 2020
0e5ae52
uses relative path to type
TinaHeiligers Sep 21, 2020
36e44b8
more type import fixes
TinaHeiligers Sep 21, 2020
d58cd0c
vega snapshot
TinaHeiligers Sep 21, 2020
438d1fd
Merge branch 'master' into usage-collection-with-new-esClient
TinaHeiligers Sep 21, 2020
57f2df3
Merge branch 'master' into usage-collection-with-new-esClient
elasticmachine Sep 22, 2020
9c16f82
Merge branch 'master' of github.com:elastic/kibana
TinaHeiligers Sep 22, 2020
2be0ee7
replaces vega snapshto with one from master
TinaHeiligers Sep 22, 2020
a9974d2
Adds 400 error to catch in get_local_license to guard against calls f…
TinaHeiligers Sep 22, 2020
4b5bcaf
Addresses some PR comments
TinaHeiligers Sep 23, 2020
540cac0
Merge branch 'master' of github.com:elastic/kibana
TinaHeiligers Sep 23, 2020
80fa55d
Updates data plugin api docs
TinaHeiligers Sep 23, 2020
873ec18
Merge branch 'master' into usage-collection-with-new-esClient
TinaHeiligers Sep 23, 2020
ce3a9a0
Changes elasticsearchClient to telemetryElasticsearchClient in monito…
TinaHeiligers Sep 23, 2020
12ca461
Reverts back to using callCluster to get the cluster info in stats route
TinaHeiligers Sep 23, 2020
94d06d5
refactors get_local_license
TinaHeiligers Sep 24, 2020
a572d75
Returns license
TinaHeiligers Sep 24, 2020
06e3b79
cleans up nodes usage API call
TinaHeiligers Sep 24, 2020
8a910ef
Merge branch 'master' into usage-collection-with-new-esClient
elasticmachine Sep 24, 2020
bedea91
Merge branch 'master' into usage-collection-with-new-esClient
elasticmachine Sep 24, 2020
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
1 change: 1 addition & 0 deletions src/plugins/data/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { DeleteDocumentParams } from 'elasticsearch';
import { DeleteScriptParams } from 'elasticsearch';
import { DeleteTemplateParams } from 'elasticsearch';
import { Duration } from 'moment';
import { ElasticsearchClient as ElasticsearchClient_2 } from 'kibana/server';
import { Ensure } from '@kbn/utility-types';
import { EnvironmentMode } from '@kbn/config';
import { ErrorToastOptions } from 'src/core/public/notifications';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
* under the License.
*/

import { savedObjectsRepositoryMock, loggingSystemMock } from '../../../../../core/server/mocks';
import {
savedObjectsRepositoryMock,
loggingSystemMock,
elasticsearchServiceMock,
} from '../../../../../core/server/mocks';
import {
CollectorOptions,
createUsageCollectionSetupMock,
Expand Down Expand Up @@ -50,6 +54,7 @@ describe('telemetry_application_usage', () => {
const getUsageCollector = jest.fn();
const registerType = jest.fn();
const callCluster = jest.fn();
const esClient = elasticsearchServiceMock.createClusterClient().asInternalUser;

beforeAll(() =>
registerApplicationUsageCollector(logger, usageCollectionMock, registerType, getUsageCollector)
Expand All @@ -62,7 +67,7 @@ describe('telemetry_application_usage', () => {

test('if no savedObjectClient initialised, return undefined', async () => {
expect(collector.isReady()).toBe(false);
expect(await collector.fetch(callCluster)).toBeUndefined();
expect(await collector.fetch(callCluster, esClient)).toBeUndefined();
jest.runTimersToTime(ROLL_INDICES_START);
});

Expand All @@ -80,7 +85,7 @@ describe('telemetry_application_usage', () => {
jest.runTimersToTime(ROLL_TOTAL_INDICES_INTERVAL); // Force rollTotals to run

expect(collector.isReady()).toBe(true);
expect(await collector.fetch(callCluster)).toStrictEqual({});
expect(await collector.fetch(callCluster, esClient)).toStrictEqual({});
expect(savedObjectClient.bulkCreate).not.toHaveBeenCalled();
});

Expand Down Expand Up @@ -137,7 +142,7 @@ describe('telemetry_application_usage', () => {

jest.runTimersToTime(ROLL_TOTAL_INDICES_INTERVAL); // Force rollTotals to run

expect(await collector.fetch(callCluster)).toStrictEqual({
expect(await collector.fetch(callCluster, esClient)).toStrictEqual({
appId: {
clicks_total: total + 1 + 10,
clicks_7_days: total + 1,
Expand Down Expand Up @@ -197,7 +202,7 @@ describe('telemetry_application_usage', () => {

getUsageCollector.mockImplementation(() => savedObjectClient);

expect(await collector.fetch(callCluster)).toStrictEqual({
expect(await collector.fetch(callCluster, esClient)).toStrictEqual({
appId: {
clicks_total: 1,
clicks_7_days: 0,
Expand Down
17 changes: 10 additions & 7 deletions src/plugins/telemetry/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
SavedObjectsClient,
Plugin,
Logger,
IClusterClient,
} from '../../../core/server';
import { registerRoutes } from './routes';
import { registerCollection } from './telemetry_collection';
Expand Down Expand Up @@ -83,6 +84,7 @@ export class TelemetryPlugin implements Plugin<TelemetryPluginSetup, TelemetryPl
private readonly fetcherTask: FetcherTask;
private savedObjectsClient?: ISavedObjectsRepository;
private uiSettingsClient?: IUiSettingsClient;
private elasticsearchClient?: IClusterClient;

constructor(initializerContext: PluginInitializerContext<TelemetryConfigType>) {
this.logger = initializerContext.logger.get();
Expand All @@ -102,8 +104,11 @@ export class TelemetryPlugin implements Plugin<TelemetryPluginSetup, TelemetryPl
const currentKibanaVersion = this.currentKibanaVersion;
const config$ = this.config$;
const isDev = this.isDev;

registerCollection(telemetryCollectionManager, elasticsearch.legacy.client);
registerCollection(
telemetryCollectionManager,
elasticsearch.legacy.client,
() => this.elasticsearchClient
);
const router = http.createRouter();

registerRoutes({
Expand All @@ -126,14 +131,12 @@ export class TelemetryPlugin implements Plugin<TelemetryPluginSetup, TelemetryPl
};
}

public async start(
core: CoreStart,
{ telemetryCollectionManager }: TelemetryPluginsDepsStart
): Promise<TelemetryPluginStart> {
const { savedObjects, uiSettings } = core;
public async start(core: CoreStart, { telemetryCollectionManager }: TelemetryPluginsDepsStart) {
const { savedObjects, uiSettings, elasticsearch } = core;
this.savedObjectsClient = savedObjects.createInternalRepository();
const savedObjectsClient = new SavedObjectsClient(this.savedObjectsClient);
this.uiSettingsClient = uiSettings.asScopedToClient(savedObjectsClient);
this.elasticsearchClient = elasticsearch.client;

try {
await handleOldSettings(savedObjectsClient, this.uiSettingsClient);
Expand Down

This file was deleted.

This file was deleted.

Loading