-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Migrate kql telemetry and scripts api #52651
Changes from 5 commits
a2b96f2
63737e1
3937a1d
a76d9e8
1e86e4d
69522fd
a619203
c82de3c
4f8a55f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* 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 { first } from 'rxjs/operators'; | ||
import { CoreSetup, Plugin, PluginInitializerContext } from 'kibana/server'; | ||
import { registerKqlTelemetryRoute } from './route'; | ||
import { UsageCollectionSetup } from '../../../usage_collection/server'; | ||
import { makeKQLUsageCollector } from './usage_collector'; | ||
|
||
export class KqlTelemetryService implements Plugin<void> { | ||
constructor(private initializerContext: PluginInitializerContext) {} | ||
|
||
public async setup( | ||
{ http, savedObjects }: CoreSetup, | ||
{ usageCollection }: { usageCollection?: UsageCollectionSetup } | ||
) { | ||
registerKqlTelemetryRoute( | ||
http.createRouter(), | ||
savedObjects, | ||
this.initializerContext.logger.get('data', 'kql-telemetry') | ||
); | ||
|
||
if (usageCollection) { | ||
const config = await this.initializerContext.config.legacy.globalConfig$ | ||
.pipe(first()) | ||
.toPromise(); | ||
makeKQLUsageCollector(usageCollection, config.kibana.index); | ||
} | ||
} | ||
|
||
public start() {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,29 +21,42 @@ import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from '../../.. | |
import { IndexPatternsService } from './index_patterns'; | ||
import { ISearchSetup } from './search'; | ||
import { SearchService } from './search/search_service'; | ||
import { ScriptsService } from './scripts'; | ||
import { KqlTelemetryService } from './kql_telemetry'; | ||
import { UsageCollectionSetup } from '../../usage_collection/server'; | ||
import { AutocompleteService } from './autocomplete'; | ||
|
||
export interface DataPluginSetup { | ||
search: ISearchSetup; | ||
} | ||
|
||
export interface DataPluginSetupDependencies { | ||
usageCollection?: UsageCollectionSetup; | ||
} | ||
export class DataServerPlugin implements Plugin<DataPluginSetup> { | ||
private readonly searchService: SearchService; | ||
private readonly scriptsService: ScriptsService; | ||
private readonly kqlTelemetryService: KqlTelemetryService; | ||
private readonly autocompleteService = new AutocompleteService(); | ||
private readonly indexPatterns = new IndexPatternsService(); | ||
|
||
constructor(initializerContext: PluginInitializerContext) { | ||
this.searchService = new SearchService(initializerContext); | ||
this.scriptsService = new ScriptsService(); | ||
this.kqlTelemetryService = new KqlTelemetryService(initializerContext); | ||
} | ||
|
||
public setup(core: CoreSetup) { | ||
public async setup(core: CoreSetup, { usageCollection }: DataPluginSetupDependencies) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not, I used to block on telemetry service setup during development, but it doesn't make sense in practice. I made the async-ness an implementation detail. |
||
this.indexPatterns.setup(core); | ||
this.scriptsService.setup(core); | ||
this.autocompleteService.setup(core); | ||
this.kqlTelemetryService.setup(core, { usageCollection }); | ||
|
||
return { | ||
search: this.searchService.setup(core), | ||
}; | ||
} | ||
|
||
public start(core: CoreStart) {} | ||
public stop() {} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should import from
public
here if possible, instead ofcommon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is used on the server, so importing from
public
won't work. Funny enough as it's not in aserver
dir, importing fromserver
also doesn't work with the current linting rules. I would like to keepcommon
for now and we can clean it up when migrating this file