Skip to content

Commit

Permalink
maps -> maps-telemetry & dynamic fields removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Caldwell committed Jun 25, 2020
1 parent bcc6209 commit 11490df
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 95 deletions.
4 changes: 3 additions & 1 deletion x-pack/plugins/maps/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export const EMS_TILES_VECTOR_TILE_PATH = 'vector/tile';
export const MAP_SAVED_OBJECT_TYPE = 'map';
export const APP_ID = 'maps';
export const APP_ICON = 'gisApp';
export const TELEMETRY_TYPE = APP_ID;
// Previously changed to maps but resulted in a mapping field 'explosion'
// should remain 'maps-telemetry' until issue is resolved
export const TELEMETRY_TYPE = 'maps-telemetry';

export const MAP_APP_PATH = `app/${APP_ID}`;
export const GIS_API_PATH = `api/${APP_ID}`;
Expand Down
31 changes: 0 additions & 31 deletions x-pack/plugins/maps/server/maps_telemetry/maps_telemetry.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ describe('buildMapsTelemetry', () => {
max: 0,
min: 0,
},
emsVectorLayersCount: {},
layerTypesCount: {},
layersCount: {
avg: 0,
max: 0,
Expand All @@ -56,35 +54,6 @@ describe('buildMapsTelemetry', () => {
max: 3,
min: 2,
},
emsVectorLayersCount: {
canada_provinces: {
avg: 0.3333333333333333,
max: 1,
min: 1,
},
france_departments: {
avg: 0.3333333333333333,
max: 1,
min: 1,
},
italy_provinces: {
avg: 0.3333333333333333,
max: 1,
min: 1,
},
},
layerTypesCount: {
TILE: {
avg: 1,
max: 1,
min: 1,
},
VECTOR: {
avg: 1.6666666666666667,
max: 2,
min: 1,
},
},
layersCount: {
avg: 2.6666666666666665,
max: 3,
Expand Down
58 changes: 1 addition & 57 deletions x-pack/plugins/maps/server/maps_telemetry/maps_telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,48 +11,13 @@ import {
SavedObjectAttribute,
} from 'kibana/server';
import { IFieldType, IIndexPattern } from 'src/plugins/data/public';
import { SOURCE_TYPES, ES_GEO_FIELD_TYPE, MAP_SAVED_OBJECT_TYPE } from '../../common/constants';
import { ES_GEO_FIELD_TYPE, MAP_SAVED_OBJECT_TYPE } from '../../common/constants';
import { LayerDescriptor } from '../../common/descriptor_types';
import { MapSavedObject } from '../../common/map_saved_object_type';
// @ts-ignore
import { getInternalRepository } from '../kibana_server_services';
import { MapsConfigType } from '../../config';

interface IStats {
[key: string]: {
min: number;
max: number;
avg: number;
};
}

interface ILayerTypeCount {
[key: string]: number;
}

function getUniqueLayerCounts(layerCountsList: ILayerTypeCount[], mapsCount: number) {
const uniqueLayerTypes = _.uniq(_.flatten(layerCountsList.map((lTypes) => Object.keys(lTypes))));

return uniqueLayerTypes.reduce((accu: IStats, type: string) => {
const typeCounts = layerCountsList.reduce(
(tCountsAccu: number[], tCounts: ILayerTypeCount): number[] => {
if (tCounts[type]) {
tCountsAccu.push(tCounts[type]);
}
return tCountsAccu;
},
[]
);
const typeCountsSum = _.sum(typeCounts);
accu[type] = {
min: typeCounts.length ? _.min(typeCounts) : 0,
max: typeCounts.length ? _.max(typeCounts) : 0,
avg: typeCountsSum ? typeCountsSum / mapsCount : 0,
};
return accu;
}, {});
}

function getIndexPatternsWithGeoFieldCount(indexPatterns: IIndexPattern[]) {
const fieldLists = indexPatterns.map((indexPattern) =>
indexPattern.attributes && indexPattern.attributes.fields
Expand Down Expand Up @@ -106,19 +71,6 @@ export function buildMapsTelemetry({
});

const layersCount = layerLists.map((lList) => lList.length);
const layerTypesCount = layerLists.map((lList) => _.countBy(lList, 'type'));

// Count of EMS Vector layers used
const emsLayersCount = layerLists.map((lList) =>
_(lList)
.countBy((layer: LayerDescriptor) => {
const isEmsFile = _.get(layer, 'sourceDescriptor.type') === SOURCE_TYPES.EMS_FILE;
return isEmsFile && _.get(layer, 'sourceDescriptor.id');
})
.pick((val, key) => key !== 'false')
.value()
);

const dataSourcesCountSum = _.sum(dataSourcesCount);
const layersCountSum = _.sum(layersCount);

Expand Down Expand Up @@ -149,14 +101,6 @@ export function buildMapsTelemetry({
max: layersCount.length ? _.max(layersCount) : 0,
avg: layersCountSum ? layersCountSum / mapsCount : 0,
},
// Count of layers by type
layerTypesCount: {
...getUniqueLayerCounts(layerTypesCount, mapsCount),
},
// Count of layer by EMS region
emsVectorLayersCount: {
...getUniqueLayerCounts(emsLayersCount, mapsCount),
},
},
};
}
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/maps/server/saved_objects/maps_telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ export const mapsTelemetrySavedObjects: SavedObjectsType = {
avg: { type: 'long' },
},
},
layerTypesCount: { dynamic: 'true', properties: {} },
emsVectorLayersCount: { dynamic: 'true', properties: {} },
},
},
},
Expand Down
8 changes: 4 additions & 4 deletions x-pack/test/api_integration/apis/telemetry/telemetry_local.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ export default function ({ getService }) {
expect(stats.stack_stats.kibana.plugins.apm.services_per_agent).to.be.an('object');
expect(stats.stack_stats.kibana.plugins.infraops.last_24_hours).to.be.an('object');
expect(stats.stack_stats.kibana.plugins.kql.defaultQueryLanguage).to.be.a('string');
expect(stats.stack_stats.kibana.plugins.maps.timeCaptured).to.be.a('string');
expect(stats.stack_stats.kibana.plugins.maps.attributes).to.be(undefined);
expect(stats.stack_stats.kibana.plugins.maps.id).to.be(undefined);
expect(stats.stack_stats.kibana.plugins.maps.type).to.be(undefined);
expect(stats.stack_stats.kibana.plugins['maps-telemetry'].timeCaptured).to.be.a('string');
expect(stats.stack_stats.kibana.plugins['maps-telemetry'].attributes).to.be(undefined);
expect(stats.stack_stats.kibana.plugins['maps-telemetry'].id).to.be(undefined);
expect(stats.stack_stats.kibana.plugins['maps-telemetry'].type).to.be(undefined);

expect(stats.stack_stats.kibana.plugins.reporting.enabled).to.be(true);
expect(stats.stack_stats.kibana.plugins.rollups.index_patterns).to.be.an('object');
Expand Down

0 comments on commit 11490df

Please sign in to comment.