-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[UsageCollection] Expose KibanaRequest to explicitly opted-in collectors
#83413
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
Changes from 4 commits
57abd1e
07a4a6c
3e48359
3328578
01ea1c4
4afc962
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 |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ | |
|
|
||
| import { savedObjectsRepositoryMock, loggingSystemMock } from '../../../../../core/server/mocks'; | ||
| import { | ||
| CollectorOptions, | ||
| Collector, | ||
| createUsageCollectionSetupMock, | ||
| } from '../../../../usage_collection/server/usage_collection.mock'; | ||
|
|
||
|
|
@@ -40,11 +40,11 @@ describe('telemetry_application_usage', () => { | |
|
|
||
| const logger = loggingSystemMock.createLogger(); | ||
|
|
||
| let collector: CollectorOptions; | ||
| let collector: Collector<unknown, unknown>; | ||
|
|
||
| const usageCollectionMock = createUsageCollectionSetupMock(); | ||
| usageCollectionMock.makeUsageCollector.mockImplementation((config) => { | ||
| collector = config; | ||
| collector = new Collector(logger, config); | ||
|
Member
Author
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. This change is required because TS would complain about |
||
| return createUsageCollectionSetupMock().makeUsageCollector(config); | ||
| }); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -157,7 +157,10 @@ export class TelemetryCollectionManagerPlugin | |
| const soClient = config.unencrypted | ||
| ? collectionSoService.getScopedClient(config.request) | ||
| : collectionSoService.createInternalRepository(); | ||
| return { callCluster, timestamp, usageCollection, esClient, soClient }; | ||
| // Provide the kibanaRequest so opted-in plugins can scope their custom clients only if the request is not encrypted | ||
| const kibanaRequest = config.unencrypted ? request : void 0; | ||
|
Member
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. why
Member
Author
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 essentially the same. But JS allows you do do |
||
|
|
||
| return { callCluster, timestamp, usageCollection, esClient, soClient, kibanaRequest }; | ||
| } | ||
|
|
||
| private async getOptInStats(optInStatus: boolean, config: StatsGetterConfig) { | ||
|
|
||
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.
I guess importing from
kibana/servervssrc/core/serverwill create a new/duplicate import in the generated docs. From what I can see this isn't a problem, but TIL.