diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 12767d69fc472..bef88d3f69a81 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -955,6 +955,7 @@ test/server_integration/plugins/status_plugin_a @elastic/kibana-core test/server_integration/plugins/status_plugin_b @elastic/kibana-core src/platform/packages/shared/kbn-std @elastic/kibana-core packages/kbn-stdio-dev-helpers @elastic/kibana-operations +src/platform/packages/shared/kbn-storage-adapter @elastic/observability-ui packages/kbn-storybook @elastic/kibana-operations x-pack/solutions/observability/plugins/streams_app @simianhacker @flash1293 @dgieselaar x-pack/solutions/observability/plugins/streams @simianhacker @flash1293 @dgieselaar @@ -990,6 +991,7 @@ src/platform/packages/private/kbn-timelion-grammar @elastic/kibana-visualization src/platform/packages/shared/kbn-timerange @elastic/obs-ux-logs-team src/platform/packages/private/kbn-tinymath @elastic/kibana-visualizations packages/kbn-tooling-log @elastic/kibana-operations +src/platform/packages/shared/kbn-traced-es-client @elastic/observability-ui x-pack/platform/plugins/private/transform @elastic/ml-ui x-pack/platform/plugins/private/translations @elastic/kibana-localization src/platform/packages/private/kbn-transpose-utils @elastic/kibana-visualizations diff --git a/package.json b/package.json index 8694c47fe0ec3..1016e135fbde9 100644 --- a/package.json +++ b/package.json @@ -936,6 +936,7 @@ "@kbn/status-plugin-a-plugin": "link:test/server_integration/plugins/status_plugin_a", "@kbn/status-plugin-b-plugin": "link:test/server_integration/plugins/status_plugin_b", "@kbn/std": "link:src/platform/packages/shared/kbn-std", + "@kbn/storage-adapter": "link:src/platform/packages/shared/kbn-storage-adapter", "@kbn/streams-app-plugin": "link:x-pack/solutions/observability/plugins/streams_app", "@kbn/streams-plugin": "link:x-pack/solutions/observability/plugins/streams", "@kbn/streams-schema": "link:x-pack/platform/packages/shared/kbn-streams-schema", @@ -957,6 +958,7 @@ "@kbn/timelion-grammar": "link:src/platform/packages/private/kbn-timelion-grammar", "@kbn/timerange": "link:src/platform/packages/shared/kbn-timerange", "@kbn/tinymath": "link:src/platform/packages/private/kbn-tinymath", + "@kbn/traced-es-client": "link:src/platform/packages/shared/kbn-traced-es-client", "@kbn/transform-plugin": "link:x-pack/platform/plugins/private/transform", "@kbn/translations-plugin": "link:x-pack/platform/plugins/private/translations", "@kbn/transpose-utils": "link:src/platform/packages/private/kbn-transpose-utils", diff --git a/x-pack/solutions/observability/packages/utils-server/es/storage/README.md b/src/platform/packages/shared/kbn-storage-adapter/README.md similarity index 100% rename from x-pack/solutions/observability/packages/utils-server/es/storage/README.md rename to src/platform/packages/shared/kbn-storage-adapter/README.md diff --git a/x-pack/solutions/observability/packages/utils-server/es/storage/index.ts b/src/platform/packages/shared/kbn-storage-adapter/index.ts similarity index 91% rename from x-pack/solutions/observability/packages/utils-server/es/storage/index.ts rename to src/platform/packages/shared/kbn-storage-adapter/index.ts index d2051b720dfe2..0b35732928f57 100644 --- a/x-pack/solutions/observability/packages/utils-server/es/storage/index.ts +++ b/src/platform/packages/shared/kbn-storage-adapter/index.ts @@ -1,9 +1,12 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". */ + import type { BulkRequest, BulkResponse, @@ -151,6 +154,6 @@ export type StorageDocumentOf = Storag properties: TStorageSettings['schema']['properties']; }> & { _id: string }; -export { StorageIndexAdapter } from './index_adapter'; +export { StorageIndexAdapter } from './src/index_adapter'; export { types } from './types'; diff --git a/src/platform/packages/shared/kbn-storage-adapter/jest.config.js b/src/platform/packages/shared/kbn-storage-adapter/jest.config.js new file mode 100644 index 0000000000000..b57eea71d6736 --- /dev/null +++ b/src/platform/packages/shared/kbn-storage-adapter/jest.config.js @@ -0,0 +1,14 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../../..', + roots: ['/src/platform/packages/shared/kbn-storage-adapter'], +}; diff --git a/src/platform/packages/shared/kbn-storage-adapter/jest.integration.config.js b/src/platform/packages/shared/kbn-storage-adapter/jest.integration.config.js new file mode 100644 index 0000000000000..fd94989254e1f --- /dev/null +++ b/src/platform/packages/shared/kbn-storage-adapter/jest.integration.config.js @@ -0,0 +1,14 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +module.exports = { + preset: '@kbn/test/jest_integration', + rootDir: '../../../../..', + roots: ['/src/platform/packages/shared/kbn-storage-adapter'], +}; diff --git a/src/platform/packages/shared/kbn-storage-adapter/kibana.jsonc b/src/platform/packages/shared/kbn-storage-adapter/kibana.jsonc new file mode 100644 index 0000000000000..7cbd23ae88225 --- /dev/null +++ b/src/platform/packages/shared/kbn-storage-adapter/kibana.jsonc @@ -0,0 +1,9 @@ +{ + "type": "shared-server", + "id": "@kbn/storage-adapter", + "owner": [ + "@elastic/observability-ui" + ], + "group": "platform", + "visibility": "shared" +} diff --git a/src/platform/packages/shared/kbn-storage-adapter/package.json b/src/platform/packages/shared/kbn-storage-adapter/package.json new file mode 100644 index 0000000000000..168be2e80833c --- /dev/null +++ b/src/platform/packages/shared/kbn-storage-adapter/package.json @@ -0,0 +1,6 @@ +{ + "name": "@kbn/storage-adapter", + "private": true, + "version": "1.0.0", + "license": "Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0" +} diff --git a/src/platform/packages/shared/kbn-storage-adapter/src/get_schema_version.ts b/src/platform/packages/shared/kbn-storage-adapter/src/get_schema_version.ts new file mode 100644 index 0000000000000..461876dc593a7 --- /dev/null +++ b/src/platform/packages/shared/kbn-storage-adapter/src/get_schema_version.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +import stringify from 'json-stable-stringify'; +import objectHash from 'object-hash'; +import { IndexStorageSettings } from '..'; + +export function getSchemaVersion(storage: IndexStorageSettings): string { + const version = objectHash(stringify(storage.schema.properties)); + return version; +} diff --git a/x-pack/solutions/observability/packages/utils-server/es/storage/index_adapter/index.ts b/src/platform/packages/shared/kbn-storage-adapter/src/index_adapter/index.ts similarity index 97% rename from x-pack/solutions/observability/packages/utils-server/es/storage/index_adapter/index.ts rename to src/platform/packages/shared/kbn-storage-adapter/src/index_adapter/index.ts index 3e5b5b9a1ae18..28b4d4c76a2ea 100644 --- a/x-pack/solutions/observability/packages/utils-server/es/storage/index_adapter/index.ts +++ b/src/platform/packages/shared/kbn-storage-adapter/src/index_adapter/index.ts @@ -1,8 +1,10 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". */ import type { @@ -35,9 +37,9 @@ import { StorageClientCleanResponse, ApplicationDocument, InternalIStorageClient, -} from '..'; +} from '../..'; import { getSchemaVersion } from '../get_schema_version'; -import { StorageMappingProperty } from '../types'; +import { StorageMappingProperty } from '../../types'; function getAliasName(name: string) { return name; diff --git a/x-pack/solutions/observability/packages/utils-server/es/storage/index_adapter/integration_tests/index.test.ts b/src/platform/packages/shared/kbn-storage-adapter/src/index_adapter/integration_tests/index.test.ts similarity index 97% rename from x-pack/solutions/observability/packages/utils-server/es/storage/index_adapter/integration_tests/index.test.ts rename to src/platform/packages/shared/kbn-storage-adapter/src/index_adapter/integration_tests/index.test.ts index 4b9327d4cc5c8..f5c637bc19db4 100644 --- a/x-pack/solutions/observability/packages/utils-server/es/storage/index_adapter/integration_tests/index.test.ts +++ b/src/platform/packages/shared/kbn-storage-adapter/src/index_adapter/integration_tests/index.test.ts @@ -1,8 +1,10 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". */ import { @@ -16,7 +18,7 @@ import { StorageClientIndexResponse, StorageIndexAdapter, type StorageSettings, -} from '../..'; +} from '../../..'; import type { ElasticsearchClient, Logger } from '@kbn/core/server'; import { httpServerMock } from '@kbn/core/server/mocks'; import * as getSchemaVersionModule from '../../get_schema_version'; diff --git a/src/platform/packages/shared/kbn-storage-adapter/tsconfig.json b/src/platform/packages/shared/kbn-storage-adapter/tsconfig.json new file mode 100644 index 0000000000000..3e324dcf4a8a0 --- /dev/null +++ b/src/platform/packages/shared/kbn-storage-adapter/tsconfig.json @@ -0,0 +1,24 @@ +{ + "extends": "../../../../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types", + "types": [ + "jest", + "node", + "react" + ] + }, + "include": [ + "**/*.ts", + "**/*.tsx", + ], + "exclude": [ + "target/**/*" + ], + "kbn_references": [ + "@kbn/core", + "@kbn/es-types", + "@kbn/es-errors", + "@kbn/core-test-helpers-kbn-server", + ] +} diff --git a/x-pack/solutions/observability/packages/utils-server/es/storage/types.ts b/src/platform/packages/shared/kbn-storage-adapter/types.ts similarity index 88% rename from x-pack/solutions/observability/packages/utils-server/es/storage/types.ts rename to src/platform/packages/shared/kbn-storage-adapter/types.ts index 08d8fecff3cf0..3ef39cb390645 100644 --- a/x-pack/solutions/observability/packages/utils-server/es/storage/types.ts +++ b/src/platform/packages/shared/kbn-storage-adapter/types.ts @@ -1,8 +1,10 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". */ import { MappingObjectProperty, MappingProperty } from '@elastic/elasticsearch/lib/api/types'; diff --git a/src/platform/packages/shared/kbn-traced-es-client/README.md b/src/platform/packages/shared/kbn-traced-es-client/README.md new file mode 100644 index 0000000000000..eb97e7122a1b8 --- /dev/null +++ b/src/platform/packages/shared/kbn-traced-es-client/README.md @@ -0,0 +1,4 @@ +# Traced ES Client + +This package provides a wrapper around the regular platform ES client which adds tracing information for better analysis. +Each operation can be given a custom name that shows up as a trace when instrumenting using APM. \ No newline at end of file diff --git a/src/platform/packages/shared/kbn-traced-es-client/index.ts b/src/platform/packages/shared/kbn-traced-es-client/index.ts new file mode 100644 index 0000000000000..6b0fcebc8e3b9 --- /dev/null +++ b/src/platform/packages/shared/kbn-traced-es-client/index.ts @@ -0,0 +1,10 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +export * from './src/create_traced_es_client'; diff --git a/src/platform/packages/shared/kbn-traced-es-client/jest.config.js b/src/platform/packages/shared/kbn-traced-es-client/jest.config.js new file mode 100644 index 0000000000000..7f1eeda7c16ff --- /dev/null +++ b/src/platform/packages/shared/kbn-traced-es-client/jest.config.js @@ -0,0 +1,14 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../../..', + roots: ['/src/platform/packages/shared/kbn-traced-es-client'], +}; diff --git a/src/platform/packages/shared/kbn-traced-es-client/kibana.jsonc b/src/platform/packages/shared/kbn-traced-es-client/kibana.jsonc new file mode 100644 index 0000000000000..eb88c4d3ef3d9 --- /dev/null +++ b/src/platform/packages/shared/kbn-traced-es-client/kibana.jsonc @@ -0,0 +1,9 @@ +{ + "type": "shared-server", + "id": "@kbn/traced-es-client", + "owner": [ + "@elastic/observability-ui" + ], + "group": "platform", + "visibility": "shared" +} diff --git a/src/platform/packages/shared/kbn-traced-es-client/package.json b/src/platform/packages/shared/kbn-traced-es-client/package.json new file mode 100644 index 0000000000000..677d5f5063122 --- /dev/null +++ b/src/platform/packages/shared/kbn-traced-es-client/package.json @@ -0,0 +1,6 @@ +{ + "name": "@kbn/traced-es-client", + "private": true, + "version": "1.0.0", + "license": "Elastic License 2.0 OR AGPL-3.0-only OR SSPL-1.0" +} diff --git a/x-pack/solutions/observability/packages/utils-server/es/client/create_observability_es_client.ts b/src/platform/packages/shared/kbn-traced-es-client/src/create_traced_es_client.ts similarity index 91% rename from x-pack/solutions/observability/packages/utils-server/es/client/create_observability_es_client.ts rename to src/platform/packages/shared/kbn-traced-es-client/src/create_traced_es_client.ts index 7731d72ffd0fe..1c95770a72510 100644 --- a/x-pack/solutions/observability/packages/utils-server/es/client/create_observability_es_client.ts +++ b/src/platform/packages/shared/kbn-traced-es-client/src/create_traced_es_client.ts @@ -1,8 +1,10 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". */ import type { @@ -19,7 +21,7 @@ import type { ESSearchRequest, InferSearchResponseOf } from '@kbn/es-types'; import { Required, ValuesType } from 'utility-types'; import { DedotObject } from '@kbn/utility-types'; import { unflattenObject } from '@kbn/task-manager-plugin/server/metrics/lib'; -import { esqlResultToPlainObjects } from '../esql_result_to_plain_objects'; +import { esqlResultToPlainObjects } from './esql_result_to_plain_objects'; type SearchRequest = ESSearchRequest & { index: string | string[]; @@ -78,7 +80,7 @@ export type EsqlQueryResponse = UnparsedEsqlResponse | ParsedEsqlResponse; * An Elasticsearch Client with a fully typed `search` method and built-in * APM instrumentation. */ -export interface ObservabilityElasticsearchClient { +export interface TracedElasticsearchClient { search( operationName: string, parameters: TSearchRequest @@ -108,7 +110,7 @@ export interface ObservabilityElasticsearchClient { client: ElasticsearchClient; } -export function createObservabilityEsClient({ +export function createTracedEsClient({ client, logger, plugin, @@ -118,7 +120,7 @@ export function createObservabilityEsClient({ logger: Logger; plugin?: string; labels?: Record; -}): ObservabilityElasticsearchClient { +}): TracedElasticsearchClient { // wraps the ES calls in a named APM span for better analysis // (otherwise it would just eg be a _search span) const callWithLogger = ( diff --git a/x-pack/solutions/observability/packages/utils-server/es/esql_result_to_plain_objects.test.ts b/src/platform/packages/shared/kbn-traced-es-client/src/esql_result_to_plain_objects.test.ts similarity index 75% rename from x-pack/solutions/observability/packages/utils-server/es/esql_result_to_plain_objects.test.ts rename to src/platform/packages/shared/kbn-traced-es-client/src/esql_result_to_plain_objects.test.ts index 55d77368cfdfb..ec8f47bf7ed4e 100644 --- a/x-pack/solutions/observability/packages/utils-server/es/esql_result_to_plain_objects.test.ts +++ b/src/platform/packages/shared/kbn-traced-es-client/src/esql_result_to_plain_objects.test.ts @@ -1,8 +1,10 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". */ import type { ESQLSearchResponse } from '@kbn/es-types'; diff --git a/x-pack/solutions/observability/packages/utils-server/es/esql_result_to_plain_objects.ts b/src/platform/packages/shared/kbn-traced-es-client/src/esql_result_to_plain_objects.ts similarity index 63% rename from x-pack/solutions/observability/packages/utils-server/es/esql_result_to_plain_objects.ts rename to src/platform/packages/shared/kbn-traced-es-client/src/esql_result_to_plain_objects.ts index 53f54b608ca35..65f936ceacf9a 100644 --- a/x-pack/solutions/observability/packages/utils-server/es/esql_result_to_plain_objects.ts +++ b/src/platform/packages/shared/kbn-traced-es-client/src/esql_result_to_plain_objects.ts @@ -1,8 +1,10 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". */ import type { ESQLSearchResponse } from '@kbn/es-types'; diff --git a/src/platform/packages/shared/kbn-traced-es-client/tsconfig.json b/src/platform/packages/shared/kbn-traced-es-client/tsconfig.json new file mode 100644 index 0000000000000..25b465c125b00 --- /dev/null +++ b/src/platform/packages/shared/kbn-traced-es-client/tsconfig.json @@ -0,0 +1,25 @@ +{ + "extends": "../../../../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types", + "types": [ + "jest", + "node", + "react" + ] + }, + "include": [ + "**/*.ts", + "**/*.tsx", + ], + "exclude": [ + "target/**/*" + ], + "kbn_references": [ + "@kbn/core", + "@kbn/es-types", + "@kbn/apm-utils", + "@kbn/utility-types", + "@kbn/task-manager-plugin", + ] +} diff --git a/tsconfig.base.json b/tsconfig.base.json index fbb52bf7b2c32..ac042567f4bba 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1904,6 +1904,8 @@ "@kbn/std/*": ["src/platform/packages/shared/kbn-std/*"], "@kbn/stdio-dev-helpers": ["packages/kbn-stdio-dev-helpers"], "@kbn/stdio-dev-helpers/*": ["packages/kbn-stdio-dev-helpers/*"], + "@kbn/storage-adapter": ["src/platform/packages/shared/kbn-storage-adapter"], + "@kbn/storage-adapter/*": ["src/platform/packages/shared/kbn-storage-adapter/*"], "@kbn/storybook": ["packages/kbn-storybook"], "@kbn/storybook/*": ["packages/kbn-storybook/*"], "@kbn/streams-app-plugin": ["x-pack/solutions/observability/plugins/streams_app"], @@ -1974,6 +1976,8 @@ "@kbn/tinymath/*": ["src/platform/packages/private/kbn-tinymath/*"], "@kbn/tooling-log": ["packages/kbn-tooling-log"], "@kbn/tooling-log/*": ["packages/kbn-tooling-log/*"], + "@kbn/traced-es-client": ["src/platform/packages/shared/kbn-traced-es-client"], + "@kbn/traced-es-client/*": ["src/platform/packages/shared/kbn-traced-es-client/*"], "@kbn/transform-plugin": ["x-pack/platform/plugins/private/transform"], "@kbn/transform-plugin/*": ["x-pack/platform/plugins/private/transform/*"], "@kbn/translations-plugin": ["x-pack/platform/plugins/private/translations"], diff --git a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/run_root_cause_analysis.ts b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/run_root_cause_analysis.ts index 94b14b4f3d12f..47ec49a6a4abd 100644 --- a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/run_root_cause_analysis.ts +++ b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/run_root_cause_analysis.ts @@ -15,7 +15,7 @@ import { findLast, pick } from 'lodash'; import moment from 'moment'; import { catchError, filter, from, map, mergeMap, Observable, of, switchMap } from 'rxjs'; import { ObservabilityAIAssistantClient } from '@kbn/observability-ai-assistant-plugin/server'; -import { ObservabilityElasticsearchClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client'; +import { TracedElasticsearchClient } from '@kbn/traced-es-client'; import { RCA_END_PROCESS_TOOL_NAME, RCA_INVESTIGATE_ENTITY_TOOL_NAME, @@ -94,7 +94,7 @@ export function runRootCauseAnalysis({ end: number; alertsClient: AlertsClient; rulesClient: RulesClient; - esClient: ObservabilityElasticsearchClient; + esClient: TracedElasticsearchClient; observabilityAIAssistantClient: ObservabilityAIAssistantClient; indices: { logs: string[]; diff --git a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/find_related_entities/analyze_fetched_related_entities.ts b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/find_related_entities/analyze_fetched_related_entities.ts index 708ae462260f5..f25d4eeff0fd0 100644 --- a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/find_related_entities/analyze_fetched_related_entities.ts +++ b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/find_related_entities/analyze_fetched_related_entities.ts @@ -15,7 +15,7 @@ import { import { sortAndTruncateAnalyzedFields } from '@kbn/observability-utils-common/llm/log_analysis/sort_and_truncate_analyzed_fields'; import { analyzeDocuments } from '@kbn/observability-utils-server/entities/analyze_documents'; import { FieldPatternResultWithChanges } from '@kbn/observability-utils-server/entities/get_log_patterns'; -import { ObservabilityElasticsearchClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client'; +import { TracedElasticsearchClient } from '@kbn/traced-es-client'; import { kqlQuery } from '@kbn/observability-utils-server/es/queries/kql_query'; import { rangeQuery } from '@kbn/observability-utils-server/es/queries/range_query'; import { chunk, isEmpty, isEqual } from 'lodash'; @@ -202,7 +202,7 @@ export async function analyzeFetchedRelatedEntities({ }: { connectorId: string; inferenceClient: InferenceClient; - esClient: ObservabilityElasticsearchClient; + esClient: TracedElasticsearchClient; start: number; end: number; searches: RelatedEntityKeywordSearch[]; diff --git a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/find_related_entities/index.ts b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/find_related_entities/index.ts index 05392db2d502c..1a6edf06acd00 100644 --- a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/find_related_entities/index.ts +++ b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/find_related_entities/index.ts @@ -11,7 +11,7 @@ import { DocumentAnalysis, TruncatedDocumentAnalysis, } from '@kbn/observability-utils-common/llm/log_analysis/document_analysis'; -import { ObservabilityElasticsearchClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client'; +import { TracedElasticsearchClient } from '@kbn/traced-es-client'; import { FieldPatternResultWithChanges } from '@kbn/observability-utils-server/entities/get_log_patterns'; import { analyzeFetchedRelatedEntities, @@ -45,7 +45,7 @@ export async function findRelatedEntities({ start: number; end: number; index: string | string[]; - esClient: ObservabilityElasticsearchClient; + esClient: TracedElasticsearchClient; entity: Record; analysis: { truncated: TruncatedDocumentAnalysis; diff --git a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/investigate_entity/index.ts b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/investigate_entity/index.ts index 1e9ae7147211b..9646a677733f3 100644 --- a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/investigate_entity/index.ts +++ b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/tasks/investigate_entity/index.ts @@ -11,7 +11,7 @@ import { analyzeDocuments } from '@kbn/observability-utils-server/entities/analy import { getDataStreamsForEntity } from '@kbn/observability-utils-server/entities/get_data_streams_for_entity'; import { getAlertsForEntity } from '@kbn/observability-utils-server/entities/signals/get_alerts_for_entity'; import { getSlosForEntity } from '@kbn/observability-utils-server/entities/signals/get_slos_for_entity'; -import { ObservabilityElasticsearchClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client'; +import { TracedElasticsearchClient } from '@kbn/traced-es-client'; import { RootCauseAnalysisContext } from '../../types'; import { stringifySummaries } from '../../util/stringify_summaries'; import { analyzeLogPatterns } from '../analyze_log_patterns'; @@ -251,7 +251,7 @@ async function analyzeDataStreamsForEntity({ end: number; kuery: string; dataStreams: string[]; - esClient: ObservabilityElasticsearchClient; + esClient: TracedElasticsearchClient; }) { const analysis = await analyzeDocuments({ esClient, diff --git a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/types.ts b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/types.ts index 6b6fa1886309c..c61e2e94a2cc1 100644 --- a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/types.ts +++ b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/root_cause_analysis/types.ts @@ -17,7 +17,7 @@ import { Logger } from '@kbn/logging'; import { AlertsClient } from '@kbn/rule-registry-plugin/server'; import { RulesClient } from '@kbn/alerting-plugin/server'; import { ObservabilityAIAssistantClient } from '@kbn/observability-ai-assistant-plugin/server'; -import { ObservabilityElasticsearchClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client'; +import { TracedElasticsearchClient } from '@kbn/traced-es-client'; import { RCA_END_PROCESS_TOOL_NAME, RCA_INVESTIGATE_ENTITY_TOOL_NAME, @@ -92,7 +92,7 @@ export interface RootCauseAnalysisContext { inferenceClient: InferenceClient; tokenLimit: number; connectorId: string; - esClient: ObservabilityElasticsearchClient; + esClient: TracedElasticsearchClient; alertsClient: AlertsClient; rulesClient: RulesClient; logger: Logger; diff --git a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/tsconfig.json b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/tsconfig.json index 59f73df4273c8..7a43777d519ed 100644 --- a/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/tsconfig.json +++ b/x-pack/solutions/observability/packages/observability-ai/observability-ai-server/tsconfig.json @@ -25,5 +25,6 @@ "@kbn/inference-common", "@kbn/observability-ai-common", "@kbn/observability-utils-server", + "@kbn/traced-es-client", ] } diff --git a/x-pack/solutions/observability/packages/utils-server/entities/analyze_documents.ts b/x-pack/solutions/observability/packages/utils-server/entities/analyze_documents.ts index bf9d85cd54747..41caa7920f9a9 100644 --- a/x-pack/solutions/observability/packages/utils-server/entities/analyze_documents.ts +++ b/x-pack/solutions/observability/packages/utils-server/entities/analyze_documents.ts @@ -8,7 +8,7 @@ import { mapValues } from 'lodash'; import { mergeSampleDocumentsWithFieldCaps } from '@kbn/observability-utils-common/llm/log_analysis/merge_sample_documents_with_field_caps'; import { DocumentAnalysis } from '@kbn/observability-utils-common/llm/log_analysis/document_analysis'; -import type { ObservabilityElasticsearchClient } from '../es/client/create_observability_es_client'; +import type { TracedElasticsearchClient } from '@kbn/traced-es-client'; import { kqlQuery } from '../es/queries/kql_query'; import { rangeQuery } from '../es/queries/range_query'; @@ -19,7 +19,7 @@ export async function analyzeDocuments({ end, index, }: { - esClient: ObservabilityElasticsearchClient; + esClient: TracedElasticsearchClient; kuery: string; start: number; end: number; diff --git a/x-pack/solutions/observability/packages/utils-server/entities/get_data_streams_for_entity.ts b/x-pack/solutions/observability/packages/utils-server/entities/get_data_streams_for_entity.ts index 43d9134c7aaf3..324ab857ea351 100644 --- a/x-pack/solutions/observability/packages/utils-server/entities/get_data_streams_for_entity.ts +++ b/x-pack/solutions/observability/packages/utils-server/entities/get_data_streams_for_entity.ts @@ -6,7 +6,7 @@ */ import { compact, uniq } from 'lodash'; -import { ObservabilityElasticsearchClient } from '../es/client/create_observability_es_client'; +import type { TracedElasticsearchClient } from '@kbn/traced-es-client'; import { excludeFrozenQuery } from '../es/queries/exclude_frozen_query'; import { kqlQuery } from '../es/queries/kql_query'; @@ -15,7 +15,7 @@ export async function getDataStreamsForEntity({ kuery, index, }: { - esClient: ObservabilityElasticsearchClient; + esClient: TracedElasticsearchClient; kuery: string; index: string | string[]; }) { diff --git a/x-pack/solutions/observability/packages/utils-server/entities/get_entities_by_fuzzy_search.ts b/x-pack/solutions/observability/packages/utils-server/entities/get_entities_by_fuzzy_search.ts index aedf89b2ab97d..f54179a67a1e2 100644 --- a/x-pack/solutions/observability/packages/utils-server/entities/get_entities_by_fuzzy_search.ts +++ b/x-pack/solutions/observability/packages/utils-server/entities/get_entities_by_fuzzy_search.ts @@ -7,7 +7,7 @@ import { castArray, orderBy } from 'lodash'; import Fuse from 'fuse.js'; -import { ObservabilityElasticsearchClient } from '../es/client/create_observability_es_client'; +import { TracedElasticsearchClient } from '@kbn/traced-es-client'; export async function getEntitiesByFuzzySearch({ esClient, @@ -16,7 +16,7 @@ export async function getEntitiesByFuzzySearch({ end, index, }: { - esClient: ObservabilityElasticsearchClient; + esClient: TracedElasticsearchClient; entity: Record; start: number; end: number; diff --git a/x-pack/solutions/observability/packages/utils-server/entities/get_log_patterns.ts b/x-pack/solutions/observability/packages/utils-server/entities/get_log_patterns.ts index b4071d665f383..d179d8d2bfab7 100644 --- a/x-pack/solutions/observability/packages/utils-server/entities/get_log_patterns.ts +++ b/x-pack/solutions/observability/packages/utils-server/entities/get_log_patterns.ts @@ -19,7 +19,7 @@ import { pValueToLabel } from '@kbn/observability-utils-common/ml/p_value_to_lab import { calculateAuto } from '@kbn/calculate-auto'; import { omit, orderBy, uniqBy } from 'lodash'; import moment from 'moment'; -import { ObservabilityElasticsearchClient } from '../es/client/create_observability_es_client'; +import { TracedElasticsearchClient } from '@kbn/traced-es-client'; import { kqlQuery } from '../es/queries/kql_query'; import { rangeQuery } from '../es/queries/range_query'; @@ -54,7 +54,7 @@ export type FieldPatternResultWithChanges = FieldPatternResult; interface CategorizeTextOptions { query: QueryDslQueryContainer; metadata: string[]; - esClient: ObservabilityElasticsearchClient; + esClient: TracedElasticsearchClient; samplingProbability: number; fields: string[]; index: string | string[]; @@ -247,7 +247,7 @@ export async function runCategorizeTextAggregation({ } interface LogPatternOptions { - esClient: ObservabilityElasticsearchClient; + esClient: TracedElasticsearchClient; start: number; end: number; index: string | string[]; diff --git a/x-pack/solutions/observability/packages/utils-server/entities/signals/get_slos_for_entity.ts b/x-pack/solutions/observability/packages/utils-server/entities/signals/get_slos_for_entity.ts index fc3a9d7b26d5c..99c58715ddaa6 100644 --- a/x-pack/solutions/observability/packages/utils-server/entities/signals/get_slos_for_entity.ts +++ b/x-pack/solutions/observability/packages/utils-server/entities/signals/get_slos_for_entity.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ObservabilityElasticsearchClient } from '../../es/client/create_observability_es_client'; +import { TracedElasticsearchClient } from '@kbn/traced-es-client'; import { kqlQuery } from '../../es/queries/kql_query'; export async function getSlosForEntity({ @@ -20,7 +20,7 @@ export async function getSlosForEntity({ start: number; end: number; entity: Record; - esClient: ObservabilityElasticsearchClient; + esClient: TracedElasticsearchClient; sloSummaryIndices: string | string[]; size: number; spaceId: string; diff --git a/x-pack/solutions/observability/packages/utils-server/es/storage/get_schema_version.ts b/x-pack/solutions/observability/packages/utils-server/es/storage/get_schema_version.ts deleted file mode 100644 index 0be986c168cba..0000000000000 --- a/x-pack/solutions/observability/packages/utils-server/es/storage/get_schema_version.ts +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import stringify from 'json-stable-stringify'; -import objectHash from 'object-hash'; -import { IndexStorageSettings } from '.'; - -export function getSchemaVersion(storage: IndexStorageSettings): string { - const version = objectHash(stringify(storage.schema.properties)); - return version; -} diff --git a/x-pack/solutions/observability/packages/utils-server/jest.integration.config.js b/x-pack/solutions/observability/packages/utils-server/jest.integration.config.js deleted file mode 100644 index bc0723cc66c2e..0000000000000 --- a/x-pack/solutions/observability/packages/utils-server/jest.integration.config.js +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -module.exports = { - preset: '@kbn/test/jest_integration', - rootDir: '../../../../..', - roots: ['/x-pack/solutions/observability/packages/utils-server'], -}; diff --git a/x-pack/solutions/observability/packages/utils-server/tsconfig.json b/x-pack/solutions/observability/packages/utils-server/tsconfig.json index 4546c8c069a95..f7cf4e0940bc0 100644 --- a/x-pack/solutions/observability/packages/utils-server/tsconfig.json +++ b/x-pack/solutions/observability/packages/utils-server/tsconfig.json @@ -16,19 +16,14 @@ "target/**/*" ], "kbn_references": [ - "@kbn/core", "@kbn/es-types", - "@kbn/apm-utils", "@kbn/es-query", "@kbn/observability-utils-common", + "@kbn/traced-es-client", "@kbn/alerting-plugin", "@kbn/rule-registry-plugin", "@kbn/rule-data-utils", "@kbn/aiops-log-pattern-analysis", "@kbn/calculate-auto", - "@kbn/utility-types", - "@kbn/task-manager-plugin", - "@kbn/es-errors", - "@kbn/core-test-helpers-kbn-server", ] } diff --git a/x-pack/solutions/observability/plugins/infra/server/routes/entities/get_data_stream_types.test.ts b/x-pack/solutions/observability/plugins/infra/server/routes/entities/get_data_stream_types.test.ts index 4879d29e156ca..5331e7b46add1 100644 --- a/x-pack/solutions/observability/plugins/infra/server/routes/entities/get_data_stream_types.test.ts +++ b/x-pack/solutions/observability/plugins/infra/server/routes/entities/get_data_stream_types.test.ts @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { ObservabilityElasticsearchClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client'; +import type { TracedElasticsearchClient } from '@kbn/traced-es-client'; import { type EntityClient } from '@kbn/entityManager-plugin/server/lib/entity_client'; import { type InfraMetricsClient } from '../../lib/helpers/get_infra_metrics_client'; import { getDataStreamTypes } from './get_data_stream_types'; @@ -22,13 +22,13 @@ jest.mock('./get_latest_entity', () => ({ describe('getDataStreamTypes', () => { let infraMetricsClient: jest.Mocked; - let obsEsClient: jest.Mocked; + let obsEsClient: jest.Mocked; let entityManagerClient: jest.Mocked; const logger = loggingSystemMock.createLogger(); beforeEach(() => { infraMetricsClient = {} as jest.Mocked; - obsEsClient = {} as jest.Mocked; + obsEsClient = {} as jest.Mocked; entityManagerClient = {} as jest.Mocked; jest.clearAllMocks(); }); diff --git a/x-pack/solutions/observability/plugins/infra/server/routes/entities/get_data_stream_types.ts b/x-pack/solutions/observability/plugins/infra/server/routes/entities/get_data_stream_types.ts index bdd592fda201a..a4666a91fb50d 100644 --- a/x-pack/solutions/observability/plugins/infra/server/routes/entities/get_data_stream_types.ts +++ b/x-pack/solutions/observability/plugins/infra/server/routes/entities/get_data_stream_types.ts @@ -9,7 +9,7 @@ import { type EntityClient } from '@kbn/entityManager-plugin/server/lib/entity_c import type { InventoryItemType } from '@kbn/metrics-data-access-plugin/common'; import { findInventoryFields } from '@kbn/metrics-data-access-plugin/common'; import { EntityDataStreamType } from '@kbn/observability-shared-plugin/common'; -import type { ObservabilityElasticsearchClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client'; +import type { TracedElasticsearchClient } from '@kbn/traced-es-client'; import { castArray } from 'lodash'; import type { Logger } from '@kbn/logging'; import { type InfraMetricsClient } from '../../lib/helpers/get_infra_metrics_client'; @@ -22,7 +22,7 @@ interface Params { entityFilterType: string; entityCentricExperienceEnabled: boolean; infraMetricsClient: InfraMetricsClient; - obsEsClient: ObservabilityElasticsearchClient; + obsEsClient: TracedElasticsearchClient; entityManagerClient: EntityClient; logger: Logger; from: string; diff --git a/x-pack/solutions/observability/plugins/infra/server/routes/entities/index.ts b/x-pack/solutions/observability/plugins/infra/server/routes/entities/index.ts index e195a6da6d72f..8c9b60589b69b 100644 --- a/x-pack/solutions/observability/plugins/infra/server/routes/entities/index.ts +++ b/x-pack/solutions/observability/plugins/infra/server/routes/entities/index.ts @@ -8,7 +8,7 @@ import { schema } from '@kbn/config-schema'; import { METRICS_APP_ID } from '@kbn/deeplinks-observability/constants'; import { entityCentricExperience } from '@kbn/observability-plugin/common'; -import { createObservabilityEsClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client'; +import { createTracedEsClient } from '@kbn/traced-es-client'; import { BUILT_IN_ENTITY_TYPES } from '@kbn/observability-shared-plugin/common'; import { getInfraMetricsClient } from '../../lib/helpers/get_infra_metrics_client'; import type { InfraBackendLibs } from '../../lib/infra_types'; @@ -55,7 +55,7 @@ export const initEntitiesConfigurationRoutes = (libs: InfraBackendLibs) => { context: requestContext, }); - const obsEsClient = createObservabilityEsClient({ + const obsEsClient = createTracedEsClient({ client: coreContext.elasticsearch.client.asCurrentUser, logger, plugin: `@kbn/${METRICS_APP_ID}-plugin`, diff --git a/x-pack/solutions/observability/plugins/infra/tsconfig.json b/x-pack/solutions/observability/plugins/infra/tsconfig.json index 618f7a5612ac9..08bc6c1bd96a3 100644 --- a/x-pack/solutions/observability/plugins/infra/tsconfig.json +++ b/x-pack/solutions/observability/plugins/infra/tsconfig.json @@ -115,12 +115,12 @@ "@kbn/core-ui-settings-common", "@kbn/entityManager-plugin", "@kbn/zod", - "@kbn/observability-utils-server", - "@kbn/observability-utils-common", "@kbn/core-plugins-server", "@kbn/config", "@kbn/response-ops-rule-params", - "@kbn/charts-theme" + "@kbn/charts-theme", + "@kbn/traced-es-client", + "@kbn/observability-utils-common" ], "exclude": ["target/**/*"] } diff --git a/x-pack/solutions/observability/plugins/investigate_app/server/routes/rca/route.ts b/x-pack/solutions/observability/plugins/investigate_app/server/routes/rca/route.ts index c4b71d7faa4b9..7aa27e88fca9c 100644 --- a/x-pack/solutions/observability/plugins/investigate_app/server/routes/rca/route.ts +++ b/x-pack/solutions/observability/plugins/investigate_app/server/routes/rca/route.ts @@ -14,7 +14,7 @@ import { import { z } from '@kbn/zod'; import datemath from '@elastic/datemath'; import { OBSERVABILITY_LOGS_DATA_ACCESS_LOG_SOURCES_ID } from '@kbn/management-settings-ids'; -import { createObservabilityEsClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client'; +import { createTracedEsClient } from '@kbn/traced-es-client'; import { preconditionFailed } from '@hapi/boom'; import { createInvestigateAppServerRoute } from '../create_investigate_app_server_route'; import { investigationRepositoryFactory } from '../../services/investigation_repository'; @@ -69,7 +69,7 @@ export const rootCauseAnalysisRoute = createInvestigateAppServerRoute({ const repository = investigationRepositoryFactory({ soClient, logger }); - const esClient = createObservabilityEsClient({ + const esClient = createTracedEsClient({ client: coreEsClient, logger, plugin: 'investigateApp', diff --git a/x-pack/solutions/observability/plugins/investigate_app/tsconfig.json b/x-pack/solutions/observability/plugins/investigate_app/tsconfig.json index cc318908336e5..c1b09e0f6a2b8 100644 --- a/x-pack/solutions/observability/plugins/investigate_app/tsconfig.json +++ b/x-pack/solutions/observability/plugins/investigate_app/tsconfig.json @@ -59,7 +59,6 @@ "@kbn/observability-plugin", "@kbn/observability-shared-plugin", "@kbn/observability-utils-browser", - "@kbn/observability-utils-server", "@kbn/presentation-containers", "@kbn/react-kibana-context-theme", "@kbn/rule-data-utils", @@ -80,6 +79,7 @@ "@kbn/utility-types-jest", "@kbn/visualization-utils", "@kbn/zod", + "@kbn/traced-es-client", "@kbn/react-hooks", ], } diff --git a/x-pack/solutions/observability/plugins/observability_ai_assistant_app/server/clients/create_observability_ai_assistant_app_es_client.ts b/x-pack/solutions/observability/plugins/observability_ai_assistant_app/server/clients/create_observability_ai_assistant_app_es_client.ts index babb6c1273370..b7f8414d4179f 100644 --- a/x-pack/solutions/observability/plugins/observability_ai_assistant_app/server/clients/create_observability_ai_assistant_app_es_client.ts +++ b/x-pack/solutions/observability/plugins/observability_ai_assistant_app/server/clients/create_observability_ai_assistant_app_es_client.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { createObservabilityEsClient } from '@kbn/observability-utils-server/es/client/create_observability_es_client'; +import { createTracedEsClient } from '@kbn/traced-es-client'; import { ElasticsearchClient, Logger } from '@kbn/core/server'; export async function createObservabilityAIAssistantAppEsClient({ @@ -15,7 +15,7 @@ export async function createObservabilityAIAssistantAppEsClient({ client: ElasticsearchClient; logger: Logger; }) { - const esClient = createObservabilityEsClient({ + const esClient = createTracedEsClient({ client, logger, plugin: 'observabilityAIAssistantApp', diff --git a/x-pack/solutions/observability/plugins/observability_ai_assistant_app/tsconfig.json b/x-pack/solutions/observability/plugins/observability_ai_assistant_app/tsconfig.json index 6dc33536ebac1..e76a8e22acc42 100644 --- a/x-pack/solutions/observability/plugins/observability_ai_assistant_app/tsconfig.json +++ b/x-pack/solutions/observability/plugins/observability_ai_assistant_app/tsconfig.json @@ -70,7 +70,6 @@ "@kbn/cloud-plugin", "@kbn/logs-data-access-plugin", "@kbn/ai-assistant-common", - "@kbn/observability-utils-server", "@kbn/observability-utils-common", "@kbn/slo-plugin", "@kbn/spaces-plugin", @@ -84,6 +83,7 @@ "@kbn/ai-assistant-icon", "@kbn/rule-data-utils", "@kbn/utility-types", + "@kbn/traced-es-client" ], "exclude": ["target/**/*"] } diff --git a/x-pack/solutions/observability/plugins/streams/server/lib/streams/assets/asset_client.ts b/x-pack/solutions/observability/plugins/streams/server/lib/streams/assets/asset_client.ts index 2406c56c809fe..a1abe9f2bd2cd 100644 --- a/x-pack/solutions/observability/plugins/streams/server/lib/streams/assets/asset_client.ts +++ b/x-pack/solutions/observability/plugins/streams/server/lib/streams/assets/asset_client.ts @@ -8,7 +8,7 @@ import { SanitizedRule } from '@kbn/alerting-plugin/common'; import { RulesClient } from '@kbn/alerting-plugin/server'; import { SavedObject, SavedObjectsClientContract } from '@kbn/core/server'; import { termQuery } from '@kbn/observability-utils-server/es/queries/term_query'; -import { IStorageClient } from '@kbn/observability-utils-server/es/storage'; +import { IStorageClient } from '@kbn/storage-adapter'; import { keyBy } from 'lodash'; import objectHash from 'object-hash'; import pLimit from 'p-limit'; diff --git a/x-pack/solutions/observability/plugins/streams/server/lib/streams/assets/asset_service.ts b/x-pack/solutions/observability/plugins/streams/server/lib/streams/assets/asset_service.ts index 47bd57433b9d8..1115e2314a247 100644 --- a/x-pack/solutions/observability/plugins/streams/server/lib/streams/assets/asset_service.ts +++ b/x-pack/solutions/observability/plugins/streams/server/lib/streams/assets/asset_service.ts @@ -6,7 +6,7 @@ */ import { CoreSetup, KibanaRequest, Logger } from '@kbn/core/server'; -import { StorageIndexAdapter } from '@kbn/observability-utils-server/es/storage'; +import { StorageIndexAdapter } from '@kbn/storage-adapter'; import { StreamsPluginStartDependencies } from '../../../types'; import { AssetClient, StoredAssetLink } from './asset_client'; import { AssetStorageSettings, assetStorageSettings } from './storage_settings'; diff --git a/x-pack/solutions/observability/plugins/streams/server/lib/streams/assets/storage_settings.ts b/x-pack/solutions/observability/plugins/streams/server/lib/streams/assets/storage_settings.ts index d5c5145c2137d..2d9515ddd281f 100644 --- a/x-pack/solutions/observability/plugins/streams/server/lib/streams/assets/storage_settings.ts +++ b/x-pack/solutions/observability/plugins/streams/server/lib/streams/assets/storage_settings.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { IndexStorageSettings, types } from '@kbn/observability-utils-server/es/storage'; +import { IndexStorageSettings, types } from '@kbn/storage-adapter'; import { ASSET_ASSET_ID, ASSET_ENTITY_ID, ASSET_ENTITY_TYPE, ASSET_TYPE } from './fields'; export const assetStorageSettings = { diff --git a/x-pack/solutions/observability/plugins/streams/server/lib/streams/service.ts b/x-pack/solutions/observability/plugins/streams/server/lib/streams/service.ts index b79159d0cfaa3..bd39469d1b040 100644 --- a/x-pack/solutions/observability/plugins/streams/server/lib/streams/service.ts +++ b/x-pack/solutions/observability/plugins/streams/server/lib/streams/service.ts @@ -6,12 +6,7 @@ */ import type { CoreSetup, KibanaRequest, Logger } from '@kbn/core/server'; -import { - IStorageClient, - StorageIndexAdapter, - StorageSettings, - types, -} from '@kbn/observability-utils-server/es/storage'; +import { IStorageClient, StorageIndexAdapter, StorageSettings, types } from '@kbn/storage-adapter'; import { StreamDefinition } from '@kbn/streams-schema'; import type { StreamsPluginStartDependencies } from '../../types'; import { StreamsClient } from './client'; diff --git a/x-pack/solutions/observability/plugins/streams/server/routes/esql/route.ts b/x-pack/solutions/observability/plugins/streams/server/routes/esql/route.ts index 33bcb3a74c6b6..73a8ab7e60b05 100644 --- a/x-pack/solutions/observability/plugins/streams/server/routes/esql/route.ts +++ b/x-pack/solutions/observability/plugins/streams/server/routes/esql/route.ts @@ -8,10 +8,7 @@ import { excludeFrozenQuery } from '@kbn/observability-utils-common/es/queries/exclude_frozen_query'; import { kqlQuery } from '@kbn/observability-utils-common/es/queries/kql_query'; import { rangeQuery } from '@kbn/observability-utils-common/es/queries/range_query'; -import { - UnparsedEsqlResponse, - createObservabilityEsClient, -} from '@kbn/observability-utils-server/es/client/create_observability_es_client'; +import { UnparsedEsqlResponse, createTracedEsClient } from '@kbn/traced-es-client'; import { z } from '@kbn/zod'; import { isNumber } from 'lodash'; import { createServerRoute } from '../create_server_route'; @@ -40,7 +37,7 @@ export const executeEsqlRoute = createServerRoute({ }), handler: async ({ params, request, logger, getScopedClients }): Promise => { const { scopedClusterClient } = await getScopedClients({ request }); - const observabilityEsClient = createObservabilityEsClient({ + const observabilityEsClient = createTracedEsClient({ client: scopedClusterClient.asCurrentUser, logger, plugin: 'streams', diff --git a/x-pack/solutions/observability/plugins/streams/tsconfig.json b/x-pack/solutions/observability/plugins/streams/tsconfig.json index 748e722f66f9f..9cfa80a21120c 100644 --- a/x-pack/solutions/observability/plugins/streams/tsconfig.json +++ b/x-pack/solutions/observability/plugins/streams/tsconfig.json @@ -36,6 +36,8 @@ "@kbn/safer-lodash-set", "@kbn/streams-schema", "@kbn/es-errors", - "@kbn/server-route-repository-utils" + "@kbn/server-route-repository-utils", + "@kbn/storage-adapter", + "@kbn/traced-es-client" ] } diff --git a/x-pack/solutions/observability/plugins/streams_app/public/components/esql_chart/controlled_esql_chart.tsx b/x-pack/solutions/observability/plugins/streams_app/public/components/esql_chart/controlled_esql_chart.tsx index 22de78d7681b2..80131f2c9af72 100644 --- a/x-pack/solutions/observability/plugins/streams_app/public/components/esql_chart/controlled_esql_chart.tsx +++ b/x-pack/solutions/observability/plugins/streams_app/public/components/esql_chart/controlled_esql_chart.tsx @@ -23,7 +23,7 @@ import { i18n } from '@kbn/i18n'; import { getTimeZone } from '@kbn/observability-utils-browser/utils/ui_settings/get_timezone'; import { css } from '@emotion/css'; import { AbortableAsyncState } from '@kbn/react-hooks'; -import type { UnparsedEsqlResponse } from '@kbn/observability-utils-server/es/client/create_observability_es_client'; +import type { UnparsedEsqlResponse } from '@kbn/traced-es-client'; import { esqlResultToTimeseries } from '../../util/esql_result_to_timeseries'; import { useKibana } from '../../hooks/use_kibana'; import { LoadingPanel } from '../loading_panel'; diff --git a/x-pack/solutions/observability/plugins/streams_app/public/util/esql_result_to_timeseries.ts b/x-pack/solutions/observability/plugins/streams_app/public/util/esql_result_to_timeseries.ts index c8c69192a681a..4b9fcf919b4cb 100644 --- a/x-pack/solutions/observability/plugins/streams_app/public/util/esql_result_to_timeseries.ts +++ b/x-pack/solutions/observability/plugins/streams_app/public/util/esql_result_to_timeseries.ts @@ -5,7 +5,7 @@ * 2.0. */ import type { AbortableAsyncState } from '@kbn/react-hooks'; -import type { UnparsedEsqlResponse } from '@kbn/observability-utils-server/es/client/create_observability_es_client'; +import type { UnparsedEsqlResponse } from '@kbn/traced-es-client'; import { orderBy } from 'lodash'; interface Timeseries { diff --git a/x-pack/solutions/observability/plugins/streams_app/tsconfig.json b/x-pack/solutions/observability/plugins/streams_app/tsconfig.json index 6bfe3e0e6a4d9..5d36a0141eda5 100644 --- a/x-pack/solutions/observability/plugins/streams_app/tsconfig.json +++ b/x-pack/solutions/observability/plugins/streams_app/tsconfig.json @@ -28,7 +28,6 @@ "@kbn/react-kibana-context-render", "@kbn/code-editor", "@kbn/observability-utils-browser", - "@kbn/observability-utils-server", "@kbn/ui-theme", "@kbn/calculate-auto", "@kbn/kibana-react-plugin", @@ -40,7 +39,6 @@ "@kbn/calculate-auto", "@kbn/streams-plugin", "@kbn/share-plugin", - "@kbn/observability-utils-server", "@kbn/code-editor", "@kbn/ui-theme", "@kbn/navigation-plugin", @@ -55,6 +53,7 @@ "@kbn/deeplinks-analytics", "@kbn/dashboard-plugin", "@kbn/react-kibana-mount", - "@kbn/fields-metadata-plugin" + "@kbn/fields-metadata-plugin", + "@kbn/traced-es-client" ] } diff --git a/yarn.lock b/yarn.lock index 1bb1ce37ea1ba..6ee15e6a71b74 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7662,6 +7662,10 @@ version "0.0.0" uid "" +"@kbn/storage-adapter@link:src/platform/packages/shared/kbn-storage-adapter": + version "0.0.0" + uid "" + "@kbn/storybook@link:packages/kbn-storybook": version "0.0.0" uid "" @@ -7802,6 +7806,10 @@ version "0.0.0" uid "" +"@kbn/traced-es-client@link:src/platform/packages/shared/kbn-traced-es-client": + version "0.0.0" + uid "" + "@kbn/transform-plugin@link:x-pack/platform/plugins/private/transform": version "0.0.0" uid ""