Skip to content

Commit

Permalink
[Maps] Add grid-resolution telemetry (elastic#99808)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck authored and kibanamachine committed May 19, 2021
1 parent 9b9f3be commit 69c1d10
Show file tree
Hide file tree
Showing 4 changed files with 250 additions and 1 deletion.
82 changes: 82 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 @@ -275,6 +275,88 @@ export function registerMapsUsageCollector(
},
},
},
resolutions: {
coarse: {
min: {
type: 'long',
_meta: { description: 'min number of grid-agg layers with coarse resolution' },
},
max: {
type: 'long',
_meta: { description: 'max number of grid-agg layers with coarse resolution' },
},
avg: {
type: 'float',
_meta: { description: 'avg number of grid-agg layers with coarse resolution' },
},
total: {
type: 'long',
_meta: {
description: 'total number of grid-agg layers with coarse resolution',
},
},
},
fine: {
min: {
type: 'long',
_meta: { description: 'min number of grid-agg layers with fine resolution' },
},
max: {
type: 'long',
_meta: { description: 'max number of grid-agg layers with fine resolution' },
},
avg: {
type: 'float',
_meta: { description: 'avg number of grid-agg layers with fine resolution' },
},
total: {
type: 'long',
_meta: {
description: 'total number of grid-agg layers with fine resolution',
},
},
},
most_fine: {
min: {
type: 'long',
_meta: { description: 'min number of grid-agg layers with most_fine resolution' },
},
max: {
type: 'long',
_meta: { description: 'max number of grid-agg layers with most_fine resolution' },
},
avg: {
type: 'float',
_meta: { description: 'avg number of grid-agg layers with most_fine resolution' },
},
total: {
type: 'long',
_meta: {
description: 'total number of grid-agg layers with most_fine resolution',
},
},
},
super_fine: {
min: {
type: 'long',
_meta: { description: 'min number of grid-agg layers with super_fine resolution' },
},
max: {
type: 'long',
_meta: { description: 'max number of grid-agg layers with super_fine resolution' },
},
avg: {
type: 'float',
_meta: { description: 'avg number of grid-agg layers with super_fine resolution' },
},
total: {
type: 'long',
_meta: {
description: 'total number of grid-agg layers with super_fine resolution',
},
},
},
},
joins: {
term: {
min: {
Expand Down
5 changes: 5 additions & 0 deletions x-pack/plugins/maps/server/maps_telemetry/maps_telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ import { MapsConfigType } from '../../config';
import { injectReferences } from '././../../common/migrations/references';
import {
getBaseMapsPerCluster,
getGridResolutionsPerCluster,
getScalingOptionsPerCluster,
getTelemetryLayerTypesPerCluster,
getTermJoinsPerCluster,
TELEMETRY_BASEMAP_COUNTS_PER_CLUSTER,
TELEMETRY_GRID_RESOLUTION_COUNTS_PER_CLUSTER,
TELEMETRY_LAYER_TYPE_COUNTS_PER_CLUSTER,
TELEMETRY_SCALING_OPTION_COUNTS_PER_CLUSTER,
TELEMETRY_TERM_JOIN_COUNTS_PER_CLUSTER,
Expand Down Expand Up @@ -66,6 +68,7 @@ export interface LayersStatsUsage {
scalingOptions: TELEMETRY_SCALING_OPTION_COUNTS_PER_CLUSTER;
joins: TELEMETRY_TERM_JOIN_COUNTS_PER_CLUSTER;
basemaps: TELEMETRY_BASEMAP_COUNTS_PER_CLUSTER;
resolutions: TELEMETRY_GRID_RESOLUTION_COUNTS_PER_CLUSTER;
attributesPerMap: {
dataSourcesCount: {
min: number;
Expand Down Expand Up @@ -264,6 +267,7 @@ export function buildMapsSavedObjectsTelemetry(layerLists: LayerDescriptor[][]):
const scalingOptions = getScalingOptionsPerCluster(layerLists);
const joins = getTermJoinsPerCluster(layerLists);
const basemaps = getBaseMapsPerCluster(layerLists);
const resolutions = getGridResolutionsPerCluster(layerLists);

return {
// Total count of maps
Expand All @@ -274,6 +278,7 @@ export function buildMapsSavedObjectsTelemetry(layerLists: LayerDescriptor[][]):
scalingOptions,
joins,
basemaps,
resolutions,
attributesPerMap: {
// Count of data sources per map
dataSourcesCount: {
Expand Down
48 changes: 47 additions & 1 deletion x-pack/plugins/maps/server/maps_telemetry/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
ESSearchSourceDescriptor,
LayerDescriptor,
} from '../../common/descriptor_types';
import { LAYER_TYPE, RENDER_AS, SCALING_TYPES, SOURCE_TYPES } from '../../common';
import { GRID_RESOLUTION, LAYER_TYPE, RENDER_AS, SCALING_TYPES, SOURCE_TYPES } from '../../common';
import {
DEFAULT_EMS_DARKMAP_ID,
DEFAULT_EMS_ROADMAP_DESATURATED_ID,
Expand Down Expand Up @@ -73,6 +73,16 @@ export interface TELEMETRY_TERM_JOIN_COUNTS_PER_CLUSTER {
[TELEMETRY_TERM_JOIN]?: ClusterCountStats;
}

export enum TELEMETRY_GRID_RESOLUTION {
COARSE = 'coarse',
FINE = 'fine',
MOST_FINE = 'most_fine',
SUPER_FINE = 'super_fine',
}
export type TELEMETRY_GRID_RESOLUTION_COUNTS_PER_CLUSTER = {
[key in TELEMETRY_GRID_RESOLUTION]?: ClusterCountStats;
};

// These capture a particular "combo" of source and layer-settings.
// They are mutually exclusive (ie. a layerDescriptor can only be a single telemetry_layer_type)
// They are more useful from a telemetry-perspective than:
Expand Down Expand Up @@ -261,6 +271,42 @@ export function getTermJoinsPerCluster(
});
}

function getGridResolution(layerDescriptor: LayerDescriptor): TELEMETRY_GRID_RESOLUTION | null {
if (
!layerDescriptor.sourceDescriptor ||
layerDescriptor.sourceDescriptor.type !== SOURCE_TYPES.ES_GEO_GRID ||
!(layerDescriptor.sourceDescriptor as ESGeoGridSourceDescriptor).resolution
) {
return null;
}

const descriptor = layerDescriptor.sourceDescriptor as ESGeoGridSourceDescriptor;

if (descriptor.resolution === GRID_RESOLUTION.COARSE) {
return TELEMETRY_GRID_RESOLUTION.COARSE;
}

if (descriptor.resolution === GRID_RESOLUTION.FINE) {
return TELEMETRY_GRID_RESOLUTION.FINE;
}

if (descriptor.resolution === GRID_RESOLUTION.MOST_FINE) {
return TELEMETRY_GRID_RESOLUTION.MOST_FINE;
}

if (descriptor.resolution === GRID_RESOLUTION.SUPER_FINE) {
return TELEMETRY_GRID_RESOLUTION.SUPER_FINE;
}

return null;
}

export function getGridResolutionsPerCluster(
layerLists: LayerDescriptor[][]
): TELEMETRY_GRID_RESOLUTION_COUNTS_PER_CLUSTER {
return getCountsByCluster(layerLists, getGridResolution);
}

export function getBaseMapsPerCluster(
layerLists: LayerDescriptor[][]
): TELEMETRY_BASEMAP_COUNTS_PER_CLUSTER {
Expand Down
116 changes: 116 additions & 0 deletions x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -3216,6 +3216,122 @@
}
}
},
"resolutions": {
"properties": {
"coarse": {
"properties": {
"min": {
"type": "long",
"_meta": {
"description": "min number of grid-agg layers with coarse resolution"
}
},
"max": {
"type": "long",
"_meta": {
"description": "max number of grid-agg layers with coarse resolution"
}
},
"avg": {
"type": "float",
"_meta": {
"description": "avg number of grid-agg layers with coarse resolution"
}
},
"total": {
"type": "long",
"_meta": {
"description": "total number of grid-agg layers with coarse resolution"
}
}
}
},
"fine": {
"properties": {
"min": {
"type": "long",
"_meta": {
"description": "min number of grid-agg layers with fine resolution"
}
},
"max": {
"type": "long",
"_meta": {
"description": "max number of grid-agg layers with fine resolution"
}
},
"avg": {
"type": "float",
"_meta": {
"description": "avg number of grid-agg layers with fine resolution"
}
},
"total": {
"type": "long",
"_meta": {
"description": "total number of grid-agg layers with fine resolution"
}
}
}
},
"most_fine": {
"properties": {
"min": {
"type": "long",
"_meta": {
"description": "min number of grid-agg layers with most_fine resolution"
}
},
"max": {
"type": "long",
"_meta": {
"description": "max number of grid-agg layers with most_fine resolution"
}
},
"avg": {
"type": "float",
"_meta": {
"description": "avg number of grid-agg layers with most_fine resolution"
}
},
"total": {
"type": "long",
"_meta": {
"description": "total number of grid-agg layers with most_fine resolution"
}
}
}
},
"super_fine": {
"properties": {
"min": {
"type": "long",
"_meta": {
"description": "min number of grid-agg layers with super_fine resolution"
}
},
"max": {
"type": "long",
"_meta": {
"description": "max number of grid-agg layers with super_fine resolution"
}
},
"avg": {
"type": "float",
"_meta": {
"description": "avg number of grid-agg layers with super_fine resolution"
}
},
"total": {
"type": "long",
"_meta": {
"description": "total number of grid-agg layers with super_fine resolution"
}
}
}
}
}
},
"joins": {
"properties": {
"term": {
Expand Down

0 comments on commit 69c1d10

Please sign in to comment.