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

[maps] remove Maps data view telemetry #152124

Merged
merged 10 commits into from
Feb 28, 2023
9 changes: 1 addition & 8 deletions x-pack/plugins/maps/server/kibana_server_services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,12 @@
*/

import { CoreStart } from '@kbn/core/server';
import { StartDeps } from './types';

let coreStart: CoreStart;
let pluginsStart: StartDeps;
export function setStartServices(core: CoreStart, plugins: StartDeps) {
export function setStartServices(core: CoreStart) {
coreStart = core;
pluginsStart = plugins;
}

export const getSavedObjectClient = (extraTypes?: string[]) => {
return coreStart.savedObjects.createInternalRepository(extraTypes);
};

export const getIndexPatternsServiceFactory = () =>
pluginsStart.data.indexPatterns.dataViewsServiceFactory;
export const getElasticsearch = () => coreStart.elasticsearch;
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ export function registerMapsUsageCollector(usageCollection?: UsageCollectionSetu
isReady: () => true,
fetch: async () => await getMapsTelemetry(),
schema: {
indexPatternsWithGeoFieldCount: { type: 'long' },
indexPatternsWithGeoPointFieldCount: { type: 'long' },
indexPatternsWithGeoShapeFieldCount: { type: 'long' },
geoShapeAggLayersCount: { type: 'long' },
mapsTotalCount: { type: 'long' },
timeCaptured: { type: 'date' },
layerTypes: {
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/maps/server/maps_telemetry/find_maps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function getMockSavedObjectsClient(perPage: number) {
} as unknown as ISavedObjectsRepository;
}

test('should process all map saved objects with single page', async () => {
test('should process all map saved objects with a single page', async () => {
const foundMapIds: string[] = [];
await findMaps(getMockSavedObjectsClient(20), async (savedObject) => {
foundMapIds.push(savedObject.id);
Expand All @@ -43,7 +43,7 @@ test('should process all map saved objects with single page', async () => {
]);
});

test('should process all map saved objects with with paging', async () => {
test('should process all map saved objects with paging', async () => {
const foundMapIds: string[] = [];
await findMaps(getMockSavedObjectsClient(2), async (savedObject) => {
foundMapIds.push(savedObject.id);
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

22 changes: 2 additions & 20 deletions x-pack/plugins/maps/server/maps_telemetry/maps_telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,19 @@
* 2.0.
*/

import { SavedObjectsClient } from '@kbn/core/server';
import {
getElasticsearch,
getIndexPatternsServiceFactory,
getSavedObjectClient,
} from '../kibana_server_services';
import { getSavedObjectClient } from '../kibana_server_services';
import { MapStats, MapStatsCollector } from './map_stats';
import { IndexPatternStats, IndexPatternStatsCollector } from './index_pattern_stats';
import { findMaps } from './find_maps';

export type MapsUsage = MapStats & IndexPatternStats;

async function getReadOnlyIndexPatternsService() {
const factory = getIndexPatternsServiceFactory();
return factory(
new SavedObjectsClient(getSavedObjectClient()),
getElasticsearch().client.asInternalUser
);
}
export type MapsUsage = MapStats;

export async function getMapsTelemetry(): Promise<MapsUsage> {
const mapStatsCollector = new MapStatsCollector();
const indexPatternService = await getReadOnlyIndexPatternsService();
const indexPatternStatsCollector = new IndexPatternStatsCollector(indexPatternService);
await findMaps(getSavedObjectClient(), async (savedObject) => {
mapStatsCollector.push(savedObject.attributes);
await indexPatternStatsCollector.push(savedObject);
});

return {
...(await indexPatternStatsCollector.getStats()),
...mapStatsCollector.getStats(),
};
}
2 changes: 1 addition & 1 deletion x-pack/plugins/maps/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,6 @@ export class MapsPlugin implements Plugin {
}

start(core: CoreStart, plugins: StartDeps) {
setStartServices(core, plugins);
setStartServices(core);
}
}
1 change: 0 additions & 1 deletion x-pack/plugins/maps/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
"@kbn/safer-lodash-set",
"@kbn/custom-integrations-plugin",
"@kbn/config-schema",
"@kbn/field-types",
"@kbn/controls-plugin",
"@kbn/shared-ux-router",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5502,18 +5502,6 @@
},
"maps": {
"properties": {
"indexPatternsWithGeoFieldCount": {
"type": "long"
},
"indexPatternsWithGeoPointFieldCount": {
"type": "long"
},
"indexPatternsWithGeoShapeFieldCount": {
"type": "long"
},
"geoShapeAggLayersCount": {
"type": "long"
},
"mapsTotalCount": {
"type": "long"
},
Expand Down
Loading