[Maps] capture metrics for layer_groups in telemetry (#144068)

* [Maps] capture metrics for layer_groups in telemetry

* [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix'

* tslint fixes

* telemetry_check fixes

* fix jest test

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Nathan Reese 2022-10-31 09:17:50 -06:00 committed by GitHub
parent be35782ed2
commit 8eeba8b22b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 70 additions and 10 deletions

View file

@ -12,14 +12,14 @@ import { MapSavedObjectAttributes } from '../map_saved_object_type';
const expecteds = [
{
layerCount: 3,
layerCount: 4,
basemapCounts: { roadmap: 1 },
joinCounts: {},
layerCounts: { ems_basemap: 1, ems_region: 1, es_agg_clusters: 1 },
layerCounts: { ems_basemap: 1, ems_region: 1, es_agg_clusters: 1, layer_group: 1 },
resolutionCounts: { coarse: 1 },
scalingCounts: {},
emsFileCounts: { italy_provinces: 1 },
layerTypeCounts: { TILE: 1, GEOJSON_VECTOR: 2 },
layerTypeCounts: { GEOJSON_VECTOR: 2, LAYER_GROUP: 1, TILE: 1 },
sourceCount: 3,
},
{
@ -93,6 +93,10 @@ describe.each(testsToRun)('LayerStatsCollector %#', (attributes, expected) => {
expect(statsCollector.getLayerCounts()).toEqual(expected.layerCounts);
});
test('getLayerTypeCounts', () => {
expect(statsCollector.getLayerTypeCounts()).toEqual(expected.layerTypeCounts);
});
test('getResolutionCounts', () => {
expect(statsCollector.getResolutionCounts()).toEqual(expected.resolutionCounts);
});

View file

@ -155,14 +155,18 @@ function getJoinKey(layerDescriptor: LayerDescriptor): JOIN_KEYS | null {
}
function getLayerKey(layerDescriptor: LayerDescriptor): LAYER_KEYS | null {
if (!layerDescriptor.sourceDescriptor) {
return null;
}
if (layerDescriptor.type === LAYER_TYPE.HEATMAP) {
return LAYER_KEYS.ES_AGG_HEATMAP;
}
if (layerDescriptor.type === LAYER_TYPE.LAYER_GROUP) {
return LAYER_KEYS.LAYER_GROUP;
}
if (!layerDescriptor.sourceDescriptor) {
return null;
}
if (layerDescriptor.sourceDescriptor.type === SOURCE_TYPES.EMS_FILE) {
return LAYER_KEYS.EMS_REGION;
}

View file

@ -6,7 +6,7 @@
"title": "Italy Map",
"description": "",
"mapStateJSON": "{\"zoom\":4.82,\"center\":{\"lon\":11.41545,\"lat\":42.0865},\"timeFilters\":{\"from\":\"now-15w\",\"to\":\"now\"},\"refreshConfig\":{\"isPaused\":false,\"interval\":0},\"query\":{\"language\":\"lucene\",\"query\":\"\"}}",
"layerListJSON": "[{\"sourceDescriptor\":{\"type\":\"EMS_TMS\",\"id\":\"road_map\"},\"id\":\"csq5v\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.65,\"visible\":true,\"style\":{\"type\":\"TILE\",\"properties\":{}},\"type\":\"TILE\"},{\"sourceDescriptor\":{\"type\":\"EMS_FILE\",\"id\":\"italy_provinces\"},\"id\":\"0oye8\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.75,\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#0c1f70\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"STATIC\",\"options\":{\"size\":10}}}},\"type\":\"GEOJSON_VECTOR\"},{\"sourceDescriptor\":{\"type\":\"ES_GEO_GRID\",\"id\":\"053fe296-f5ae-4cb0-9e73-a5752cb9ba74\",\"indexPatternId\":\"d3d7af60-4c81-11e8-b3d7-01146121b73d\",\"geoField\":\"DestLocation\",\"requestType\":\"point\",\"resolution\":\"COARSE\"},\"id\":\"1gx22\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.75,\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"Count\",\"name\":\"doc_count\",\"origin\":\"source\"},\"color\":\"Greens\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"Count\",\"name\":\"doc_count\",\"origin\":\"source\"},\"minSize\":4,\"maxSize\":32}}}},\"type\":\"GEOJSON_VECTOR\"}]",
"layerListJSON": "[{\"id\":\"123\",\"label\":\"Layer Group\",\"sourceDescriptor\":null,\"type\":\"LAYER_GROUP\"},{\"sourceDescriptor\":{\"type\":\"EMS_TMS\",\"id\":\"road_map\"},\"id\":\"csq5v\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.65,\"visible\":true,\"style\":{\"type\":\"TILE\",\"properties\":{}},\"type\":\"TILE\"},{\"sourceDescriptor\":{\"type\":\"EMS_FILE\",\"id\":\"italy_provinces\"},\"id\":\"0oye8\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.75,\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#0c1f70\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"STATIC\",\"options\":{\"size\":10}}}},\"type\":\"GEOJSON_VECTOR\"},{\"sourceDescriptor\":{\"type\":\"ES_GEO_GRID\",\"id\":\"053fe296-f5ae-4cb0-9e73-a5752cb9ba74\",\"indexPatternId\":\"d3d7af60-4c81-11e8-b3d7-01146121b73d\",\"geoField\":\"DestLocation\",\"requestType\":\"point\",\"resolution\":\"COARSE\"},\"id\":\"1gx22\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.75,\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"Count\",\"name\":\"doc_count\",\"origin\":\"source\"},\"color\":\"Greens\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"Count\",\"name\":\"doc_count\",\"origin\":\"source\"},\"minSize\":4,\"maxSize\":32}}}},\"type\":\"GEOJSON_VECTOR\"}]",
"uiStateJSON": "{}"
},
"references": [

View file

@ -29,6 +29,7 @@ export enum LAYER_KEYS {
EMS_REGION = 'ems_region',
EMS_BASEMAP = 'ems_basemap',
KBN_TMS_RASTER = 'kbn_tms_raster',
LAYER_GROUP = 'layer_group',
UX_TMS_RASTER = 'ux_tms_raster', // configured in the UX layer wizard of Maps
UX_TMS_MVT = 'ux_tms_mvt', // configured in the UX layer wizard of Maps
UX_WMS = 'ux_wms', // configured in the UX layer wizard of Maps

View file

@ -166,6 +166,18 @@ export function registerMapsUsageCollector(usageCollection?: UsageCollectionSetu
_meta: { description: 'total number of kbn tms layers in cluster' },
},
},
layer_group: {
min: { type: 'long', _meta: { description: 'min number of layer groups per map' } },
max: { type: 'long', _meta: { description: 'max number of layer groups per map' } },
avg: {
type: 'float',
_meta: { description: 'avg number of layer groups per map' },
},
total: {
type: 'long',
_meta: { description: 'total number of layer groups in cluster' },
},
},
ux_tms_mvt: {
min: { type: 'long', _meta: { description: 'min number of ux tms-mvt layers per map' } },
max: { type: 'long', _meta: { description: 'max number of ux tms-mvt layers per map' } },

View file

@ -84,6 +84,12 @@ test('returns expected telemetry data from saved objects', () => {
min: 1,
total: 1,
},
layer_group: {
avg: 0.2,
max: 1,
min: 1,
total: 1,
},
},
scalingOptions: {
limit: {
@ -151,6 +157,11 @@ test('returns expected telemetry data from saved objects', () => {
max: 1,
min: 1,
},
LAYER_GROUP: {
avg: 0.2,
max: 1,
min: 1,
},
TILE: {
avg: 0.6,
max: 1,
@ -163,8 +174,8 @@ test('returns expected telemetry data from saved objects', () => {
},
},
layersCount: {
avg: 2,
max: 3,
avg: 2.2,
max: 4,
min: 1,
},
},

View file

@ -5618,6 +5618,34 @@
}
}
},
"layer_group": {
"properties": {
"min": {
"type": "long",
"_meta": {
"description": "min number of layer groups per map"
}
},
"max": {
"type": "long",
"_meta": {
"description": "max number of layer groups per map"
}
},
"avg": {
"type": "float",
"_meta": {
"description": "avg number of layer groups per map"
}
},
"total": {
"type": "long",
"_meta": {
"description": "total number of layer groups in cluster"
}
}
}
},
"ux_tms_mvt": {
"properties": {
"min": {