mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
# Backport This will backport the following commits from `main` to `8.x`: - [Add logging to importer. Closes issue #192212 (#192234)](https://github.com/elastic/kibana/pull/192234) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Kyra Cho","email":"wsc2119@columbia.edu"},"sourceCommit":{"committedDate":"2024-10-08T01:58:32Z","message":"Add logging to importer. Closes issue #192212 (#192234)\n\n## Summary\r\nHello, this closes issue #192212 by adding a custom logger to the\r\nimporter, making debugging issues easier.\r\n### Checklist\r\n\r\nDelete any items that are not applicable to this PR.\r\n\r\n- [N/A] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n- [N/A]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios TODO\r\n- [ ] [Flaky Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\r\nused on any tests changed TODO\r\n- [N/A] Any UI touched in this PR is usable by keyboard only (learn more\r\nabout [keyboard accessibility](https://webaim.org/techniques/keyboard/))\r\n- [N/A] Any UI touched in this PR does not create any new axe failures\r\n(run axe in browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n- [N/A] If a plugin configuration key changed, check if it needs to be\r\nallowlisted in the cloud and added to the [docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n- [N/A] This renders correctly on smaller devices using a responsive\r\nlayout. (You can test this [in your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n- [N/A] This was checked for [cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n\r\n### For maintainers\r\n\r\n- [X] This was checked for breaking API changes and was [labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n(no API changes)\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"c36a8943982b92afd593a521d5a0bf2de06deb01","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Core","release_note:skip","💝community","v9.0.0","backport:prev-minor","v8.16.0"],"title":"Add logging to importer. Closes issue #192212","number":192234,"url":"https://github.com/elastic/kibana/pull/192234","mergeCommit":{"message":"Add logging to importer. Closes issue #192212 (#192234)\n\n## Summary\r\nHello, this closes issue #192212 by adding a custom logger to the\r\nimporter, making debugging issues easier.\r\n### Checklist\r\n\r\nDelete any items that are not applicable to this PR.\r\n\r\n- [N/A] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n- [N/A]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios TODO\r\n- [ ] [Flaky Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\r\nused on any tests changed TODO\r\n- [N/A] Any UI touched in this PR is usable by keyboard only (learn more\r\nabout [keyboard accessibility](https://webaim.org/techniques/keyboard/))\r\n- [N/A] Any UI touched in this PR does not create any new axe failures\r\n(run axe in browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n- [N/A] If a plugin configuration key changed, check if it needs to be\r\nallowlisted in the cloud and added to the [docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n- [N/A] This renders correctly on smaller devices using a responsive\r\nlayout. (You can test this [in your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n- [N/A] This was checked for [cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n\r\n### For maintainers\r\n\r\n- [X] This was checked for breaking API changes and was [labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n(no API changes)\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"c36a8943982b92afd593a521d5a0bf2de06deb01"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/192234","number":192234,"mergeCommit":{"message":"Add logging to importer. Closes issue #192212 (#192234)\n\n## Summary\r\nHello, this closes issue #192212 by adding a custom logger to the\r\nimporter, making debugging issues easier.\r\n### Checklist\r\n\r\nDelete any items that are not applicable to this PR.\r\n\r\n- [N/A] Any text added follows [EUI's writing\r\nguidelines](https://elastic.github.io/eui/#/guidelines/writing), uses\r\nsentence case text and includes [i18n\r\nsupport](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)\r\n- [N/A]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios TODO\r\n- [ ] [Flaky Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\r\nused on any tests changed TODO\r\n- [N/A] Any UI touched in this PR is usable by keyboard only (learn more\r\nabout [keyboard accessibility](https://webaim.org/techniques/keyboard/))\r\n- [N/A] Any UI touched in this PR does not create any new axe failures\r\n(run axe in browser:\r\n[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),\r\n[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))\r\n- [N/A] If a plugin configuration key changed, check if it needs to be\r\nallowlisted in the cloud and added to the [docker\r\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\r\n- [N/A] This renders correctly on smaller devices using a responsive\r\nlayout. (You can test this [in your\r\nbrowser](https://www.browserstack.com/guide/responsive-testing-on-local-server))\r\n- [N/A] This was checked for [cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n\r\n### For maintainers\r\n\r\n- [X] This was checked for breaking API changes and was [labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n(no API changes)\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>","sha":"c36a8943982b92afd593a521d5a0bf2de06deb01"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Kyra Cho <wsc2119@columbia.edu>
This commit is contained in:
parent
fcd831cd94
commit
0bdfdbfbf0
4 changed files with 34 additions and 0 deletions
|
@ -9,6 +9,7 @@
|
|||
|
||||
import type { SavedObjectsImportResponse } from '@kbn/core-saved-objects-common';
|
||||
import type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
|
||||
import type { Logger } from '@kbn/logging';
|
||||
import type {
|
||||
ISavedObjectTypeRegistry,
|
||||
ISavedObjectsImporter,
|
||||
|
@ -27,15 +28,18 @@ export class SavedObjectsImporter implements ISavedObjectsImporter {
|
|||
readonly #typeRegistry: ISavedObjectTypeRegistry;
|
||||
readonly #importSizeLimit: number;
|
||||
readonly #importHooks: Record<string, SavedObjectsImportHook[]>;
|
||||
readonly #log: Logger;
|
||||
|
||||
constructor({
|
||||
savedObjectsClient,
|
||||
typeRegistry,
|
||||
importSizeLimit,
|
||||
logger,
|
||||
}: {
|
||||
savedObjectsClient: SavedObjectsClientContract;
|
||||
typeRegistry: ISavedObjectTypeRegistry;
|
||||
importSizeLimit: number;
|
||||
logger: Logger;
|
||||
}) {
|
||||
this.#savedObjectsClient = savedObjectsClient;
|
||||
this.#typeRegistry = typeRegistry;
|
||||
|
@ -46,6 +50,7 @@ export class SavedObjectsImporter implements ISavedObjectsImporter {
|
|||
}
|
||||
return hooks;
|
||||
}, {} as Record<string, SavedObjectsImportHook[]>);
|
||||
this.#log = logger;
|
||||
}
|
||||
|
||||
public import({
|
||||
|
@ -57,6 +62,7 @@ export class SavedObjectsImporter implements ISavedObjectsImporter {
|
|||
compatibilityMode,
|
||||
managed,
|
||||
}: SavedObjectsImportOptions): Promise<SavedObjectsImportResponse> {
|
||||
this.#log.debug('Starting the import process');
|
||||
return importSavedObjectsFromStream({
|
||||
readStream,
|
||||
createNewCopies,
|
||||
|
@ -80,6 +86,7 @@ export class SavedObjectsImporter implements ISavedObjectsImporter {
|
|||
retries,
|
||||
managed,
|
||||
}: SavedObjectsResolveImportErrorsOptions): Promise<SavedObjectsImportResponse> {
|
||||
this.#log.debug('Resolving import errors');
|
||||
return resolveSavedObjectsImportErrors({
|
||||
readStream,
|
||||
createNewCopies,
|
||||
|
|
|
@ -376,6 +376,7 @@ export class SavedObjectsService
|
|||
savedObjectsClient,
|
||||
typeRegistry: this.typeRegistry,
|
||||
importSizeLimit: options?.importSizeLimit ?? this.config!.maxImportExportSize,
|
||||
logger: this.logger.get('importer'),
|
||||
}),
|
||||
getTypeRegistry: () => this.typeRegistry,
|
||||
getDefaultIndex: () => MAIN_SAVED_OBJECT_INDEX,
|
||||
|
|
|
@ -13,6 +13,7 @@ import supertest from 'supertest';
|
|||
import { SavedObjectsErrorHelpers } from '@kbn/core-saved-objects-server';
|
||||
import { savedObjectsClientMock } from '@kbn/core-saved-objects-api-server-mocks';
|
||||
import type { ICoreUsageStatsClient } from '@kbn/core-usage-data-base-server-internal';
|
||||
import type { Logger, LogLevelId } from '@kbn/logging';
|
||||
import {
|
||||
coreUsageStatsClientMock,
|
||||
coreUsageDataServiceMock,
|
||||
|
@ -56,6 +57,17 @@ describe(`POST ${URL}`, () => {
|
|||
references: [],
|
||||
managed: false,
|
||||
};
|
||||
const mockLogger: jest.Mocked<Logger> = {
|
||||
debug: jest.fn(),
|
||||
info: jest.fn(),
|
||||
error: jest.fn(),
|
||||
warn: jest.fn(),
|
||||
trace: jest.fn(),
|
||||
fatal: jest.fn(),
|
||||
log: jest.fn(),
|
||||
isLevelEnabled: jest.fn((level: LogLevelId) => true),
|
||||
get: jest.fn(() => mockLogger),
|
||||
};
|
||||
|
||||
beforeEach(async () => {
|
||||
({ server, httpSetup, handlerContext } = await setupServer());
|
||||
|
@ -76,6 +88,7 @@ describe(`POST ${URL}`, () => {
|
|||
savedObjectsClient,
|
||||
typeRegistry: handlerContext.savedObjects.typeRegistry,
|
||||
importSizeLimit: 10000,
|
||||
logger: mockLogger,
|
||||
});
|
||||
handlerContext.savedObjects.getImporter = jest
|
||||
.fn()
|
||||
|
|
|
@ -12,6 +12,7 @@ jest.mock('uuid');
|
|||
import supertest from 'supertest';
|
||||
import { savedObjectsClientMock } from '@kbn/core-saved-objects-api-server-mocks';
|
||||
import type { ICoreUsageStatsClient } from '@kbn/core-usage-data-base-server-internal';
|
||||
import type { Logger, LogLevelId } from '@kbn/logging';
|
||||
import {
|
||||
coreUsageStatsClientMock,
|
||||
coreUsageDataServiceMock,
|
||||
|
@ -61,6 +62,17 @@ describe(`POST ${URL}`, () => {
|
|||
references: [],
|
||||
managed: false,
|
||||
};
|
||||
const mockLogger: jest.Mocked<Logger> = {
|
||||
debug: jest.fn(),
|
||||
info: jest.fn(),
|
||||
error: jest.fn(),
|
||||
warn: jest.fn(),
|
||||
trace: jest.fn(),
|
||||
fatal: jest.fn(),
|
||||
log: jest.fn(),
|
||||
isLevelEnabled: jest.fn((level: LogLevelId) => true),
|
||||
get: jest.fn(() => mockLogger),
|
||||
};
|
||||
|
||||
beforeEach(async () => {
|
||||
({ server, httpSetup, handlerContext } = await setupServer());
|
||||
|
@ -82,6 +94,7 @@ describe(`POST ${URL}`, () => {
|
|||
savedObjectsClient,
|
||||
typeRegistry: handlerContext.savedObjects.typeRegistry,
|
||||
importSizeLimit: 10000,
|
||||
logger: mockLogger,
|
||||
});
|
||||
|
||||
handlerContext.savedObjects.getImporter = jest
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue