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

TelemetryCollectionManager: Use X-Pack strategy as an OSS overwrite #84477

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 0 additions & 2 deletions src/plugins/telemetry/server/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* under the License.
*/

import moment from 'moment';
import { Observable, Subscription, timer } from 'rxjs';
import { take } from 'rxjs/operators';
// @ts-ignore
Expand Down Expand Up @@ -213,7 +212,6 @@ export class FetcherTask {
private async fetchTelemetry() {
return await this.telemetryCollectionManager!.getStats({
unencrypted: false,
timestamp: moment().valueOf(),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how it slipped in the previous PR (#83791) 😱

TS builds should have complained at least! 🤔

});
}

Expand Down
1 change: 0 additions & 1 deletion src/plugins/telemetry/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export const plugin = (initializerContext: PluginInitializerContext<TelemetryCon
export { constants };
export {
getClusterUuids,
getLocalLicense,
getLocalStats,
TelemetryLocalStats,
DATA_TELEMETRY_ID,
Expand Down
15 changes: 2 additions & 13 deletions src/plugins/telemetry/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ import {
SavedObjectsClient,
Plugin,
Logger,
IClusterClient,
UiSettingsServiceStart,
SavedObjectsServiceStart,
} from '../../../core/server';
import { registerRoutes } from './routes';
import { registerCollection } from './telemetry_collection';
Expand Down Expand Up @@ -88,8 +86,6 @@ export class TelemetryPlugin implements Plugin<TelemetryPluginSetup, TelemetryPl
*/
private readonly oldUiSettingsHandled$ = new AsyncSubject();
private savedObjectsClient?: ISavedObjectsRepository;
private elasticsearchClient?: IClusterClient;
private savedObjectsService?: SavedObjectsServiceStart;

constructor(initializerContext: PluginInitializerContext<TelemetryConfigType>) {
this.logger = initializerContext.logger.get();
Expand All @@ -109,12 +105,7 @@ export class TelemetryPlugin implements Plugin<TelemetryPluginSetup, TelemetryPl
const currentKibanaVersion = this.currentKibanaVersion;
const config$ = this.config$;
const isDev = this.isDev;
registerCollection(
telemetryCollectionManager,
elasticsearch.legacy.client,
() => this.elasticsearchClient,
() => this.savedObjectsService
);
registerCollection(telemetryCollectionManager);
const router = http.createRouter();

registerRoutes({
Expand All @@ -138,11 +129,9 @@ export class TelemetryPlugin implements Plugin<TelemetryPluginSetup, TelemetryPl
}

public start(core: CoreStart, { telemetryCollectionManager }: TelemetryPluginsDepsStart) {
const { savedObjects, uiSettings, elasticsearch } = core;
const { savedObjects, uiSettings } = core;
const savedObjectsInternalRepository = savedObjects.createInternalRepository();
this.savedObjectsClient = savedObjectsInternalRepository;
this.elasticsearchClient = elasticsearch.client;
this.savedObjectsService = savedObjects;

// Not catching nor awaiting these promises because they should never reject
this.handleOldUiSettings(uiSettings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export type TelemetryLocalStats = ReturnType<typeof handleLocalStats>;
* @param {Object} config contains the usageCollection, callCluster (deprecated), the esClient and Saved Objects client scoped to the request or the internal repository, and the kibana request
* @param {Object} StatsCollectionContext contains logger and version (string)
*/
export const getLocalStats: StatsGetter<{}, TelemetryLocalStats> = async (
export const getLocalStats: StatsGetter<TelemetryLocalStats> = async (
clustersDetails,
config,
context
Expand Down
1 change: 0 additions & 1 deletion src/plugins/telemetry/server/telemetry_collection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@ export {
buildDataTelemetryPayload,
} from './get_data_telemetry';
export { getLocalStats, TelemetryLocalStats } from './get_local_stats';
export { getLocalLicense } from './get_local_license';
export { getClusterUuids } from './get_cluster_stats';
export { registerCollection } from './register_collection';
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,17 @@
* under the License.
*/

import { ILegacyClusterClient, SavedObjectsServiceStart } from 'kibana/server';
import { TelemetryCollectionManagerPluginSetup } from 'src/plugins/telemetry_collection_manager/server';
import { IClusterClient } from '../../../../../src/core/server';
import { getLocalStats } from './get_local_stats';
import { getClusterUuids } from './get_cluster_stats';
import { getLocalLicense } from './get_local_license';

export function registerCollection(
telemetryCollectionManager: TelemetryCollectionManagerPluginSetup,
esCluster: ILegacyClusterClient,
esClientGetter: () => IClusterClient | undefined,
soServiceGetter: () => SavedObjectsServiceStart | undefined
telemetryCollectionManager: TelemetryCollectionManagerPluginSetup
) {
telemetryCollectionManager.setCollection({
esCluster,
esClientGetter,
soServiceGetter,
telemetryCollectionManager.setCollectionStrategy({
title: 'local',
priority: 0,
statsGetter: getLocalStats,
clusterDetailsGetter: getClusterUuids,
licenseGetter: getLocalLicense,
});
}
2 changes: 0 additions & 2 deletions src/plugins/telemetry_collection_manager/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@ export function plugin(initializerContext: PluginInitializerContext) {
export {
TelemetryCollectionManagerPluginSetup,
TelemetryCollectionManagerPluginStart,
ESLicense,
StatsCollectionConfig,
StatsGetter,
StatsGetterConfig,
StatsCollectionContext,
ClusterDetails,
ClusterDetailsGetter,
LicenseGetter,
UsageStatsPayload,
} from './types';
Loading