mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
* [TSVB] Validation telemetry removal * Update telemetry check oss_plugins.json * Remove unnecessary async function, usageCollection from optional plugins and fix telemetry_local test
This commit is contained in:
parent
d6edde4cc2
commit
e2647645d7
10 changed files with 4 additions and 218 deletions
|
@ -4942,13 +4942,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"tsvb-validation": {
|
||||
"properties": {
|
||||
"failed_validations": {
|
||||
"type": "long"
|
||||
}
|
||||
}
|
||||
},
|
||||
"vis_type_vega": {
|
||||
"properties": {
|
||||
"vega_lib_specs_total": {
|
||||
|
|
|
@ -5,6 +5,5 @@
|
|||
"server": true,
|
||||
"ui": true,
|
||||
"requiredPlugins": ["charts", "data", "expressions", "visualizations", "visualize"],
|
||||
"optionalPlugins": ["usageCollection"],
|
||||
"requiredBundles": ["kibanaUtils", "kibanaReact"]
|
||||
}
|
||||
|
|
|
@ -37,8 +37,6 @@ export const config: PluginConfigDescriptor<VisTypeTimeseriesConfig> = {
|
|||
schema: configSchema,
|
||||
};
|
||||
|
||||
export { ValidationTelemetryServiceSetup } from './validation_telemetry';
|
||||
|
||||
export {
|
||||
AbstractSearchStrategy,
|
||||
ReqFacade,
|
||||
|
|
|
@ -31,7 +31,6 @@ import { Observable } from 'rxjs';
|
|||
import { Server } from '@hapi/hapi';
|
||||
import { VisTypeTimeseriesConfig } from './config';
|
||||
import { getVisData, GetVisData, GetVisDataOptions } from './lib/get_vis_data';
|
||||
import { ValidationTelemetryService } from './validation_telemetry';
|
||||
import { UsageCollectionSetup } from '../../usage_collection/server';
|
||||
import { PluginStart } from '../../data/server';
|
||||
import { visDataRoutes } from './routes/vis';
|
||||
|
@ -72,11 +71,8 @@ export interface Framework {
|
|||
}
|
||||
|
||||
export class VisTypeTimeseriesPlugin implements Plugin<VisTypeTimeseriesSetup> {
|
||||
private validationTelementryService: ValidationTelemetryService;
|
||||
|
||||
constructor(private readonly initializerContext: PluginInitializerContext) {
|
||||
this.initializerContext = initializerContext;
|
||||
this.validationTelementryService = new ValidationTelemetryService();
|
||||
}
|
||||
|
||||
public setup(
|
||||
|
@ -102,15 +98,8 @@ export class VisTypeTimeseriesPlugin implements Plugin<VisTypeTimeseriesSetup> {
|
|||
searchStrategyRegistry,
|
||||
};
|
||||
|
||||
(async () => {
|
||||
const validationTelemetry = await this.validationTelementryService.setup(core, {
|
||||
...plugins,
|
||||
globalConfig$,
|
||||
});
|
||||
visDataRoutes(router, framework, validationTelemetry);
|
||||
|
||||
fieldsRoutes(framework);
|
||||
})();
|
||||
visDataRoutes(router, framework);
|
||||
fieldsRoutes(framework);
|
||||
|
||||
return {
|
||||
getVisData: async (
|
||||
|
|
|
@ -23,16 +23,11 @@ import { ensureNoUnsafeProperties } from '@kbn/std';
|
|||
import { getVisData, GetVisDataOptions } from '../lib/get_vis_data';
|
||||
import { visPayloadSchema } from '../../common/vis_schema';
|
||||
import { ROUTES } from '../../common/constants';
|
||||
import { ValidationTelemetryServiceSetup } from '../index';
|
||||
import { Framework } from '../plugin';
|
||||
|
||||
const escapeHatch = schema.object({}, { unknowns: 'allow' });
|
||||
|
||||
export const visDataRoutes = (
|
||||
router: IRouter,
|
||||
framework: Framework,
|
||||
{ logFailedValidation }: ValidationTelemetryServiceSetup
|
||||
) => {
|
||||
export const visDataRoutes = (router: IRouter, framework: Framework) => {
|
||||
router.post(
|
||||
{
|
||||
path: ROUTES.VIS_DATA,
|
||||
|
@ -52,9 +47,7 @@ export const visDataRoutes = (
|
|||
try {
|
||||
visPayloadSchema.validate(request.body);
|
||||
} catch (error) {
|
||||
logFailedValidation();
|
||||
|
||||
framework.logger.warn(
|
||||
framework.logger.debug(
|
||||
`Request validation error: ${error.message}. This most likely means your TSVB visualization contains outdated configuration. You can report this problem under https://github.com/elastic/kibana/issues/new?template=Bug_report.md`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
export { tsvbTelemetrySavedObjectType } from './tsvb_telemetry';
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { flow } from 'lodash';
|
||||
import { SavedObjectMigrationFn, SavedObjectsType } from 'kibana/server';
|
||||
|
||||
const resetCount: SavedObjectMigrationFn<any, any> = (doc) => ({
|
||||
...doc,
|
||||
attributes: {
|
||||
...doc.attributes,
|
||||
failedRequests: 0,
|
||||
},
|
||||
});
|
||||
|
||||
export const tsvbTelemetrySavedObjectType: SavedObjectsType = {
|
||||
name: 'tsvb-validation-telemetry',
|
||||
hidden: false,
|
||||
namespaceType: 'agnostic',
|
||||
mappings: {
|
||||
properties: {
|
||||
failedRequests: {
|
||||
type: 'long',
|
||||
},
|
||||
},
|
||||
},
|
||||
migrations: {
|
||||
'7.7.0': flow(resetCount),
|
||||
'7.8.0': flow(resetCount),
|
||||
'7.9.0': flow(resetCount),
|
||||
'7.10.0': flow(resetCount),
|
||||
},
|
||||
};
|
|
@ -1,20 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
export * from './validation_telemetry_service';
|
|
@ -1,97 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { CoreSetup, Plugin, PluginInitializerContext } from 'kibana/server';
|
||||
import { UsageCollectionSetup } from '../../../usage_collection/server';
|
||||
import { tsvbTelemetrySavedObjectType } from '../saved_objects';
|
||||
|
||||
export interface ValidationTelemetryServiceSetup {
|
||||
logFailedValidation: () => void;
|
||||
}
|
||||
export interface Usage {
|
||||
failed_validations: number;
|
||||
}
|
||||
|
||||
export class ValidationTelemetryService implements Plugin<ValidationTelemetryServiceSetup> {
|
||||
private kibanaIndex: string = '';
|
||||
async setup(
|
||||
core: CoreSetup,
|
||||
{
|
||||
usageCollection,
|
||||
globalConfig$,
|
||||
}: {
|
||||
usageCollection?: UsageCollectionSetup;
|
||||
globalConfig$: PluginInitializerContext['config']['legacy']['globalConfig$'];
|
||||
}
|
||||
) {
|
||||
core.savedObjects.registerType(tsvbTelemetrySavedObjectType);
|
||||
globalConfig$.subscribe((config) => {
|
||||
this.kibanaIndex = config.kibana.index;
|
||||
});
|
||||
if (usageCollection) {
|
||||
usageCollection.registerCollector(
|
||||
usageCollection.makeUsageCollector<Usage>({
|
||||
type: 'tsvb-validation',
|
||||
isReady: () => this.kibanaIndex !== '',
|
||||
fetch: async ({ esClient }) => {
|
||||
try {
|
||||
const { body: response } = await esClient.get(
|
||||
{
|
||||
index: this.kibanaIndex,
|
||||
id: 'tsvb-validation-telemetry:tsvb-validation-telemetry',
|
||||
},
|
||||
{ ignore: [404] }
|
||||
);
|
||||
return {
|
||||
failed_validations:
|
||||
response?._source?.['tsvb-validation-telemetry']?.failedRequests || 0,
|
||||
};
|
||||
} catch (err) {
|
||||
return {
|
||||
failed_validations: 0,
|
||||
};
|
||||
}
|
||||
},
|
||||
schema: {
|
||||
failed_validations: { type: 'long' },
|
||||
},
|
||||
})
|
||||
);
|
||||
}
|
||||
const internalRepositoryPromise = core
|
||||
.getStartServices()
|
||||
.then(([start]) => start.savedObjects.createInternalRepository());
|
||||
|
||||
return {
|
||||
logFailedValidation: async () => {
|
||||
try {
|
||||
const internalRepository = await internalRepositoryPromise;
|
||||
await internalRepository.incrementCounter(
|
||||
'tsvb-validation-telemetry',
|
||||
'tsvb-validation-telemetry',
|
||||
['failedRequests']
|
||||
);
|
||||
} catch (e) {
|
||||
// swallow error, validation telemetry shouldn't fail anything else
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
start() {}
|
||||
}
|
|
@ -77,7 +77,6 @@ export default function ({ getService }) {
|
|||
expect(stats.stack_stats.kibana.plugins.ui_counters).to.be.an('object');
|
||||
expect(stats.stack_stats.kibana.plugins.application_usage).to.be.an('object');
|
||||
expect(stats.stack_stats.kibana.plugins.kql.defaultQueryLanguage).to.be.a('string');
|
||||
expect(stats.stack_stats.kibana.plugins['tsvb-validation']).to.be.an('object');
|
||||
expect(stats.stack_stats.kibana.plugins.localization).to.be.an('object');
|
||||
expect(stats.stack_stats.kibana.plugins.csp.strict).to.be(false);
|
||||
expect(stats.stack_stats.kibana.plugins.csp.warnLegacyBrowsers).to.be(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue