Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into chore/tel-no-spla…
Browse files Browse the repository at this point in the history
…sh-page
  • Loading branch information
Joel Griffith committed Nov 12, 2019
2 parents fe98b93 + 19f7e99 commit b84c88f
Show file tree
Hide file tree
Showing 47 changed files with 72,565 additions and 44,500 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ describe('esArchiver: createCreateIndexStream()', () => {
sinon.assert.calledWith(client.indices.create, {
method: 'PUT',
index: 'index',
include_type_name: false,
body: {
settings: undefined,
mappings: undefined,
Expand Down
4 changes: 0 additions & 4 deletions src/es_archiver/lib/indices/create_index_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ export function createCreateIndexStream({ client, stats, skipExisting, log }) {

async function handleIndex(record) {
const { index, settings, mappings, aliases } = record.value;

// Determine if the mapping belongs to a pre-7.0 instance, for BWC tests, mainly
const isPre7Mapping = !!mappings && Object.keys(mappings).length > 0 && !mappings.properties;
const isKibana = index.startsWith('.kibana');

async function attemptToCreate(attemptNumber = 1) {
Expand All @@ -55,7 +52,6 @@ export function createCreateIndexStream({ client, stats, skipExisting, log }) {
await client.indices.create({
method: 'PUT',
index,
include_type_name: isPre7Mapping,
body: {
settings,
mappings,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"indices.create": {
"url_params": {
"include_type_name": "__flag__",
"wait_for_active_shards": "",
"timeout": "",
"master_timeout": ""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"indices.get": {
"url_params": {
"include_type_name": "__flag__",
"local": "__flag__",
"ignore_unavailable": "__flag__",
"allow_no_indices": "__flag__",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"indices.get_field_mapping": {
"url_params": {
"include_type_name": "__flag__",
"include_defaults": "__flag__",
"ignore_unavailable": "__flag__",
"allow_no_indices": "__flag__",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"indices.get_template": {
"url_params": {
"include_type_name": "__flag__",
"flat_settings": "__flag__",
"master_timeout": "",
"local": "__flag__"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"indices.put_template": {
"url_params": {
"include_type_name": "__flag__",
"order": "",
"create": "__flag__",
"timeout": "",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"indices.rollover": {
"url_params": {
"include_type_name": "__flag__",
"timeout": "",
"dry_run": "__flag__",
"master_timeout": "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function getUniqueLayerCounts(layerCountsList, mapsCount) {
}, {});
}

export function buildMapsTelemetry(savedObjects) {
export function buildMapsTelemetry(savedObjects, settings) {
const layerLists = savedObjects
.map(savedMapObject =>
JSON.parse(savedMapObject.attributes.layerListJSON));
Expand All @@ -57,7 +57,8 @@ export function buildMapsTelemetry(savedObjects) {

const dataSourcesCountSum = _.sum(dataSourcesCount);
const layersCountSum = _.sum(layersCount);
const mapsTelem = {
return {
settings,
// Total count of maps
mapsTotalCount: mapsCount,
// Time of capture
Expand Down Expand Up @@ -85,7 +86,6 @@ export function buildMapsTelemetry(savedObjects) {
}
}
};
return mapsTelem;
}

async function getSavedObjects(savedObjectsClient) {
Expand All @@ -98,7 +98,10 @@ async function getSavedObjects(savedObjectsClient) {
export async function getMapsTelemetry(server, callCluster) {
const savedObjectsClient = getSavedObjectsClient(server, callCluster);
const savedObjects = await getSavedObjects(savedObjectsClient);
const mapsTelemetry = buildMapsTelemetry(savedObjects);
const settings = {
showMapVisualizationTypes: server.config().get('xpack.maps.showMapVisualizationTypes')
};
const mapsTelemetry = buildMapsTelemetry(savedObjects, settings);

return await savedObjectsClient.create('maps-telemetry',
mapsTelemetry, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,79 +10,87 @@ import { buildMapsTelemetry } from './maps_telemetry';

describe('buildMapsTelemetry', () => {

const settings = { showMapVisualizationTypes: false };

test('returns zeroed telemetry data when there are no saved objects',
async () => {

const gisMaps = [];
const result = buildMapsTelemetry(gisMaps);
const result = buildMapsTelemetry(gisMaps, settings);

expect(result).toMatchObject({
'attributesPerMap': {
'dataSourcesCount': {
'avg': 0,
'max': 0,
'min': 0
attributesPerMap: {
dataSourcesCount: {
avg: 0,
max: 0,
min: 0
},
'emsVectorLayersCount': {},
'layerTypesCount': {},
'layersCount': {
'avg': 0,
'max': 0,
'min': 0
emsVectorLayersCount: {},
layerTypesCount: {},
layersCount: {
avg: 0,
max: 0,
min: 0
}
},
'mapsTotalCount': 0
mapsTotalCount: 0,
settings: {
showMapVisualizationTypes: false
}
});
});

test('returns expected telemetry data from saved objects', async () => {

const gisMaps = savedObjectsPayload.saved_objects;
const result = buildMapsTelemetry(gisMaps);
const result = buildMapsTelemetry(gisMaps, settings);

expect(result).toMatchObject({
'attributesPerMap': {
'dataSourcesCount': {
'avg': 2.6666666666666665,
'max': 3,
'min': 2
attributesPerMap: {
dataSourcesCount: {
avg: 2.6666666666666665,
max: 3,
min: 2
},
'emsVectorLayersCount': {
'canada_provinces': {
'avg': 0.3333333333333333,
'max': 1,
'min': 1
emsVectorLayersCount: {
canada_provinces: {
avg: 0.3333333333333333,
max: 1,
min: 1
},
'france_departments': {
'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
italy_provinces: {
avg: 0.3333333333333333,
max: 1,
min: 1
}
},
'layerTypesCount': {
'TILE': {
'avg': 1,
'max': 1,
'min': 1
layerTypesCount: {
TILE: {
avg: 1,
max: 1,
min: 1
},
'VECTOR': {
'avg': 1.6666666666666667,
'max': 2,
'min': 1
VECTOR: {
avg: 1.6666666666666667,
max: 2,
min: 1
}
},
'layersCount': {
'avg': 2.6666666666666665,
'max': 3,
'min': 2
layersCount: {
avg: 2.6666666666666665,
max: 3,
min: 2
}
},
'mapsTotalCount': 3
mapsTotalCount: 3,
settings: {
showMapVisualizationTypes: false
}
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export const reindexActionsFactory = (

async getFlatSettings(indexName: string) {
const flatSettings = (await callCluster('transport.request', {
path: `/${encodeURIComponent(indexName)}?flat_settings=true&include_type_name=false`,
path: `/${encodeURIComponent(indexName)}?flat_settings=true`,
})) as { [indexName: string]: FlatSettings };

if (!flatSettings[indexName]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export default function ({ getService }) {
'max_terms_count',
'lifecycle',
'routing_partition_size',
'force_memory_term_dictionary',
'max_docvalue_fields_search',
'merge',
'max_refresh_listeners',
Expand Down
Loading

0 comments on commit b84c88f

Please sign in to comment.