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] capture metrics for layer_groups in telemetry #144068

Merged
merged 6 commits into from
Oct 31, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
{
Expand Down Expand Up @@ -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);
});
Expand Down
12 changes: 8 additions & 4 deletions x-pack/plugins/maps/common/telemetry/layer_stats_collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/maps/common/telemetry/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions x-pack/plugins/maps/server/maps_telemetry/collectors/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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,
Expand All @@ -163,8 +174,8 @@ test('returns expected telemetry data from saved objects', () => {
},
},
layersCount: {
avg: 2,
max: 3,
avg: 2.2,
max: 4,
min: 1,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down