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

Revert usageCollection removal #23

Closed
wants to merge 5 commits into from
Closed
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
17 changes: 13 additions & 4 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
"interpreter": "src/legacy/core_plugins/interpreter",
"kbn": "src/legacy/core_plugins/kibana",
"kbnDocViews": "src/legacy/core_plugins/kbn_doc_views",
"management": ["src/legacy/core_plugins/management", "src/plugins/management"],
"management": [
"src/legacy/core_plugins/management",
"src/plugins/management"
],
"maps_legacy": "src/plugins/maps_legacy",
"indexPatternManagement": "src/plugins/index_pattern_management",
"advancedSettings": "src/plugins/advanced_settings",
Expand All @@ -39,7 +42,10 @@
"security": "src/plugins/security_oss",
"server": "src/legacy/server",
"statusPage": "src/legacy/core_plugins/status_page",
"telemetry": ["src/plugins/telemetry", "src/plugins/telemetry_management_section"],
"telemetry": [
"src/plugins/telemetry",
"src/plugins/telemetry_management_section"
],
"tileMap": "src/plugins/tile_map",
"timelion": ["src/plugins/timelion", "src/plugins/vis_type_timelion"],
"uiActions": "src/plugins/ui_actions",
Expand All @@ -54,8 +60,11 @@
"visTypeXy": "src/plugins/vis_type_xy",
"visualizations": "src/plugins/visualizations",
"visualize": "src/plugins/visualize",
"apmOss": "src/plugins/apm_oss"
"apmOss": "src/plugins/apm_oss",
"usageCollection": "src/plugins/usage_collection"
},
"exclude": ["src/legacy/ui/ui_render/ui_render_mixin.js"],
"exclude": [
"src/legacy/ui/ui_render/ui_render_mixin.js"
],
"translations": []
}
2 changes: 1 addition & 1 deletion packages/kbn-analytics/src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { Report, ReportManager } from './report';
import { ApplicationUsage } from './metrics';

export interface ReporterConfig {
http: ReportHTTP;
// http: ReportHTTP;
storage?: Storage;
checkInterval?: number;
debug?: boolean;
Expand Down
14 changes: 11 additions & 3 deletions src/plugins/data/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@
"version": "kibana",
"server": true,
"ui": true,
"requiredPlugins": ["expressions", "uiActions"],
"optionalPlugins": [],
"requiredPlugins": [
"expressions",
"uiActions"
],
"optionalPlugins": ["usageCollection"],
"extraPublicDirs": ["common", "common/utils/abort_utils"],
"requiredBundles": ["kibanaUtils", "kibanaReact", "inspector"]
"requiredBundles": [
"usageCollection",
"kibanaUtils",
"kibanaReact",
"inspector"
]
}

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { SEARCH_EVENT_TYPE, SearchUsageCollector } from './types';
import { METRIC_TYPE } from '@kbn/analytics';
import { from } from 'rxjs';

describe.skip('Search Usage Collector', () => {
describe('Search Usage Collector', () => {
let mockCoreSetup: MockedKeys<CoreSetup>;
let mockUsageCollectionSetup: Setup;
let usageCollector: SearchUsageCollector;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/public/search/collectors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
* under the License.
*/

// export { createUsageCollector } from './create_usage_collector';
export { createUsageCollector } from './create_usage_collector';
export { SEARCH_EVENT_TYPE, SearchUsageCollector } from './types';
4 changes: 2 additions & 2 deletions src/plugins/data/public/search/search_interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
ISearchOptions,
ES_SEARCH_STRATEGY,
} from '../../common';
// import { SearchUsageCollector } from './collectors';
import { SearchUsageCollector } from './collectors';
import { SearchTimeoutError, PainlessError, isPainlessError, TimeoutErrorMode } from './errors';
import { toMountPoint } from '../../../kibana_react/public';

Expand All @@ -38,7 +38,7 @@ export interface SearchInterceptorDeps {
uiSettings: CoreSetup['uiSettings'];
startServices: Promise<[CoreStart, any, unknown]>;
toasts: ToastsSetup;
// usageCollector?: SearchUsageCollector;
usageCollector?: SearchUsageCollector;
}

export class SearchInterceptor {
Expand Down
17 changes: 8 additions & 9 deletions src/plugins/data/public/search/search_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import { getCallMsearch } from './legacy';
import { AggsService, AggsStartDependencies } from './aggs';
import { IndexPatternsContract } from '../index_patterns/index_patterns';
import { ISearchInterceptor, SearchInterceptor } from './search_interceptor';
// import { SearchUsageCollector, createUsageCollector } from './collectors';
// import { UsageCollectionSetup } from '../../../usage_collection/public';
import { SearchUsageCollector, createUsageCollector } from './collectors';
import { UsageCollectionSetup } from '../../../usage_collection/public';
import { esdsl, esRawResponse } from './expressions';
import { ExpressionsSetup } from '../../../expressions/public';
import { ConfigSchema } from '../../config';
Expand All @@ -50,7 +50,7 @@ import { aggShardDelay } from '../../common/search/aggs/buckets/shard_delay_fn';
/** @internal */
export interface SearchServiceSetupDependencies {
expressions: ExpressionsSetup;
// usageCollection?: UsageCollectionSetup;
usageCollection?: UsageCollectionSetup;
}

/** @internal */
Expand All @@ -63,16 +63,15 @@ export class SearchService implements Plugin<ISearchSetup, ISearchStart> {
private readonly aggsService = new AggsService();
private readonly searchSourceService = new SearchSourceService();
private searchInterceptor!: ISearchInterceptor;
// private usageCollector?: SearchUsageCollector;
private usageCollector?: SearchUsageCollector;

constructor(private initializerContext: PluginInitializerContext<ConfigSchema>) {}

public setup(
{ http, getStartServices, notifications, uiSettings }: CoreSetup,
// { expressions, usageCollection }: SearchServiceSetupDependencies
{ expressions }: SearchServiceSetupDependencies
{ expressions, usageCollection }: SearchServiceSetupDependencies
): ISearchSetup {
// this.usageCollector = createUsageCollector(getStartServices, usageCollection);
this.usageCollector = createUsageCollector(getStartServices, usageCollection);

/**
* A global object that intercepts all searches and provides convenience methods for cancelling
Expand All @@ -83,7 +82,7 @@ export class SearchService implements Plugin<ISearchSetup, ISearchStart> {
http,
uiSettings,
startServices: getStartServices(),
usageCollector: undefined, // this.usageCollector!,
usageCollector: this.usageCollector!,
});

expressions.registerFunction(esdsl);
Expand All @@ -101,7 +100,7 @@ export class SearchService implements Plugin<ISearchSetup, ISearchStart> {

return {
aggs,
usageCollector: undefined, // this.usageCollector!,
usageCollector: this.usageCollector!,
__enhance: (enhancements: SearchEnhancements) => {
this.searchInterceptor = enhancements.searchInterceptor;
},
Expand Down
8 changes: 5 additions & 3 deletions src/plugins/telemetry/public/services/telemetry_sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ export class TelemetrySender {
// mark that we are working so future requests are ignored until we're done
this.isSending = true;
try {
const telemetryUrl = this.telemetryService.getTelemetryUrl();
const telemetryData: any | any[] = await this.telemetryService.fetchTelemetry();
const clusters: string[] = [].concat(telemetryData);
// const telemetryUrl = this.telemetryService.getTelemetryUrl();
// const telemetryData: any | any[] = await this.telemetryService.fetchTelemetry();
// const clusters: string[] = [].concat(telemetryData);
/*
await Promise.all(
clusters.map(
async (cluster) =>
Expand All @@ -85,6 +86,7 @@ export class TelemetrySender {
})
)
);
*/
this.lastReported = `${Date.now()}`;
this.saveToBrowser();
} catch (err) {
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/telemetry/public/services/telemetry_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export class TelemetryService {
};

public fetchTelemetry = async ({ unencrypted = false } = {}) => {
/*
const now = moment();
return this.http.post('/api/telemetry/v2/clusters/_stats', {
body: JSON.stringify({
Expand All @@ -132,6 +133,8 @@ export class TelemetryService {
},
}),
});
*/
return;
};

public setOptIn = async (optedIn: boolean): Promise<boolean> => {
Expand Down